V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wjx0912
V2EX  ›  Rust

请教一行代码, use cargo_modules

  •  
  •   wjx0912 · 2022-11-18 10:22:05 +08:00 · 830 次点击
    这是一个创建于 497 天前的主题,其中的信息可能已经有所发展或是发生改变。
    https://github.com/regexident/cargo-modules/blob/main/src/main.rs#L11
    第 11 行:
    use cargo_modules::options::Options;
    这个 cargo_modules 是表示什么,google 没搜到。

    谢谢了
    6 条回复    2022-11-21 17:11:57 +08:00
    wenLiangcan
        1
    wenLiangcan  
       2022-11-18 12:26:11 +08:00 via iPhone
    看你的 GitHub 链接,大概就是这个项目本身内部的名为 cargo_modules 这个模块吧,你 url 应该也打错了,把下划线打成了 杠
    araaaa
        2
    araaaa  
       2022-11-18 12:44:50 +08:00
    要引入 cargo-modules 这种名称的 crate 必须换成下划线 cargo_modules
    wjx0912
        3
    wjx0912  
    OP
       2022-11-18 13:44:48 +08:00
    @wenLiangcan url 没错啊
    wjx0912
        4
    wjx0912  
    OP
       2022-11-18 13:44:54 +08:00
    @araaaa 你说的应该是正解。谢谢
    akaHenry
        5
    akaHenry  
       2022-11-21 11:46:13 +08:00
    cargo_modules 指的是本项目自身的模块.

    cargo-modules 包名, 在包模块导入时, rust 会自动转成 cargo_modules 方式来导入(约定规范).

    社区主流包命名风格是 - 模式, 导入是 _ 模式. (自动转换)

    要习惯这个约定.
    wjx0912
        6
    wjx0912  
    OP
       2022-11-21 17:11:57 +08:00
    @akaHenry 明白了。谢谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2873 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 11:28 · PVG 19:28 · LAX 04:28 · JFK 07:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.