Type complete scope for std namespace


I usually prefer typing std::one::two::Type instead of the way usually showed in the examples:

use std::one; // use std::one::two::Type etc

because otherwise while reviewing big files i constantly need to check if that type came from std:: or some other crate or belongs to some module in current crate etc. But I find that sometimes this works:

let a: std::sync::Arc<std::sync::Mutex<Type>> = something;

and sometime it gives an error that no module called blah blah found etc. In that case if I do something like this:

let a: ::std::sync::Arc<::std::sync::Mutex<Type>> = something;

it starts working again.

I am a little confused about this. Can someone point out what exactly is the difference between std:: and ::std:: ? I don’t want to do use std::sync; and then sync::Arc::new() etc. I want complete scope resolution std::sync::Arc::new() instead.


This gist should explain matters, but the relevant part from the summary is:

There are two kinds of paths in Rust: use paths and non-use paths. The former are relative to the root module, the latter to the current module.