【问题标题】:Where can I find the `std::collections` module on my computer?我在哪里可以找到我电脑上的 `std::collections` 模块?
【发布时间】:2021-06-16 02:28:06
【问题描述】:

我目前正在学习 Rust 中的模块和 crates,我认为通过查看一个真实且非常常用的模块可以学得最好:std::collections。我希望能够查看此包的实际文件。但是,我在我的电脑上找不到它。我查看了创建项目的文件夹(和所有子文件夹)以及C:/users/(username)/.cargo 文件夹。我正在运行 x64 Windows 10 PC。请让我知道在我的系统上哪里可以找到std::collections 模块。谢谢!

【问题讨论】:

  • 专业提示:VoidTools.com/Everything
  • 您最好的选择可能是查看 github 上的 source,或者克隆编译器 repo
  • Std 是预构建的,因为它需要夜间编译器以及很长时间来构建。除非你把它放在那里,否则你不会找到源代码。
  • @Dai 嗯那个链接失效了。
  • @transitor 非常感谢,这就是我要找的东西!

标签: rust rust-cargo


【解决方案1】:

通过rustup 检索到的组件的默认位置在$HOME/.rustup/ 中,由工具链组织。源代码是rust-src 组件的一部分,可能需要通过rustup component add rust-src 手动安装。然后可以在 lib/rustlib/src/rust/library/std 中找到 std 板条箱。

所以 Windows 上 std::collections 模块的完整路径应该是:

C:\Users\<USER>\.rustup\toolchains\<TOOLCHAIN>\lib\rustlib\src\rust\library\std\src\collections

另请参阅:Where is the source code of Rust target components?

【讨论】:

  • 请注意,只有安装了rust-src组件(rustup component add rust-src)才会出现
  • @Jmb 我已将其添加为答案的一部分。我想我总是忘记这一点,因为 rust-analyzer installs it automatically.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多