Function macro_tools::container_kind::of_type
source · pub fn of_type(ty: &Type) -> ContainerKind
Expand description
Return kind of container specified by type.
Good to verify alloc::vec::Vec< i32 >
is vector.
Good to verify std::collections::HashMap< i32, i32 >
is hash map.
§Basic use-case.
use macro_tools::exposed::*;
let code = qt!( std::collections::HashMap< i32, i32 > );
let tree_type = syn::parse2::< syn::Type >( code ).unwrap();
let kind = container_kind::of_type( &tree_type );
assert_eq!( kind, container_kind::ContainerKind::HashMap );