While reading this, I came across this concept , I couldn't find a single normal description, can anyone tell me something?
I'm not sure, but from this description:
We introduce a special macro metavar
$crate
which expands to::foo
when a macro was imported through crate identfoo
, and to nothing when it was defined in the crate where it is being expanded.$crate::bar::baz
will be an absolute path either way.
I'm guessing the hack was something like having a root module with the same name as your crate, so ::foo
written in the macro would refer to that module when used within the crate, while that same ::foo
referred to the crate itself when used from outside.
Also, 2018 edition changed the meaning of such paths:
https://doc.rust-lang.org/edition-guide/rust-2018/path-changes.html#the-crate-keyword-refers-to-the-current-crate
The prefix
::
previously referred to either the crate root or an external crate; it now unambiguously refers to an external crate. For instance,::foo::bar
always refers to the namebar
inside the external cratefoo
.
Thank you!!!, I didn't even think about it, that's the only explanation
example from old version of std :
the usage of underline function of println! macro (also reexported from mod std):