gpt4 book ai didi

rust - 这行中的双冒号是什么意思?

转载 作者:行者123 更新时间:2023-12-03 11:32:07 51 4
gpt4 key购买 nike

这个line来自 rust libc crate。这里的双冒号有什么用?我认为它将 c_uint 从 crate 根目录带入范围,但我找不到它在 crate 根目录中定义的位置。

pub type speed_t = ::c_uint;

最佳答案

https://doc.rust-lang.org/reference/paths.html#path-qualifiers

Paths can be denoted with various leading qualifiers to change the meaning of how it is resolved.

::

Paths starting with :: are considered to be global paths where the segments of the path start being resolved from the crate root. Each identifier in the path must resolve to an item.


所以你的想法是正确的,它是从 crate 根解决的。

I can't find where its defined in the crate root.


libc没有在 crate 根中定义任何东西,而是 crate 根重新导出与编译目标匹配的子模块的内容。
所以 on unix “ crate 根”包含 fixed_width_ints 暴露的任何内容和 unix子模块。前者对你真的没用,但后者... does define a c_uint symbol .

关于rust - 这行中的双冒号是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65955573/

51 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com