This line is from rust libc crate. What is the use of double colon here? I thought its bringing c_uint in the scope from the crate root but I can't find where its defined in the crate root.
pub type speed_t = ::c_uint;
This line is from rust libc crate. What is the use of double colon here? I thought its bringing c_uint in the scope from the crate root but I can't find where its defined in the crate root.
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.
So your idea was correct, it is resolving from the crate root.
I can't find where its defined in the crate root.
well libc doesn't in-and-of-itself define anything at the crate root, instead the crate root re-exports the content of the submodule matching the compilation target.
So on unix the "crate root" contains anything exposed by the fixed_width_ints and unix submodules. The former is not really useful for you, but the latter... does define a c_uint symbol.
This syntax works in libc because its compiled using the 2015 Edition of Rust. The Paths reference includes a note:
Edition Differences: In the 2015 Edition, the crate root contains a variety of different items, including external crates, default crates such as std and core, and items in the top level of the crate (including use imports).
Beginning with the 2018 Edition, paths starting with :: can only reference crates.
In 2015, the ::c_uint would find the re-exported type, whereas in 2018 it won't. There were a number of module resolution changes that are described with more detail in the Edition Guide.
You can test it out on the playground (you can change editions in the advanced options menu next to Debug and Stable).