You can either use attribute or refer to it with the full path:
struct Something { count: i8, } impl std::fmt::Display for Something { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{}", self.count) } }
Note that inside the module, the paths of the element are relative, so you need to either use some super or an absolute path (the best choice, in my opinion):
mod inner { struct Something { count: i8, } impl ::std::fmt::Display for Something { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { write!(f, "{}", self.count) } } }
There is a middle ground where you use module, but not a dash:
use std::fmt; impl fmt::Display for Something { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.count) } }
And if you are just worried about entering text, you can use the module, but I suppose making it too short, this complicates the understanding:
use std::fmt as f; impl f::Display for Something { fn fmt(&self, f: &mut f::Formatter) -> f::Result { write!(f, "{}", self.count) } }
source share