qf!
API reference on docs.rs: qf!.
qf! recursively qualifies common unqualified standard-library types. It is
mainly useful in generated code, where relying on imports from the caller would
be impolite.
You write
Roughly expands to
type Messages = qf!(Option<Vec<String>>);
let messages: Messages = Some(vec![String::from("hello")]);
assert_eq!(messages.as_ref().map(Vec::len), Some(1));
type Messages = ::core::option::Option<
::std::vec::Vec<::std::string::String>,
>;
let messages: Messages = Some(vec![String::from("hello")]);
assert_eq!(messages.as_ref().map(Vec::len), Some(1));
The recognized names are:
String,Box, andVec;HashMap,HashSet,BTreeMap, andBTreeSet;OptionandArc.
Only single-segment paths are rewritten. A deliberately qualified path such as
application::String is preserved, because writing the qualifier is how the
caller says that this is not std::string::String.