Function macro_tools::type_container_kind
source · [−]pub fn type_container_kind(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.
Sample
use proc_macro_tools::*;
use quote::quote;
let code = quote!( std::collections::HashMap< i32, i32 > );
let tree_type = syn::parse2::< syn::Type >( code ).unwrap();
let kind = type_container_kind( &tree_type );
assert_eq!( kind, ContainerKind::HashMap );