Function wproc_macro::type_optional_container_kind[][src]

pub fn type_optional_container_kind(ty: &Type) -> (ContainerKind, bool)
Expand description

Return kind of container specified by type. Unlike type_container_kind it also understand optional types.

Good to verify Option< alloc::vec::Vec< i32 > > is optional vector.

Sample

use wproc_macro::*;
use quote::quote;

let code = quote!( Option< std::collections::HashMap< i32, i32 > > );
let tree_type = syn::parse2::< syn::Type >( code ).unwrap();
let ( kind, optional ) = type_optional_container_kind( &tree_type );
assert_eq!( kind, ContainerKind::HashMap );
assert_eq!( optional, true );