Function proc_macro_tools::type_rightmost
source · [−]Expand description
Check is the rightmost item of path refering a type is specified type.
Good to verify core::option::Option< i32 >
is optional.
Good to verify alloc::vec::Vec< i32 >
is vector.
Sample
use proc_macro_tools::*;
let code = qt!( core::option::Option< i32 > );
let tree_type = syn::parse2::< syn::Type >( code ).unwrap();
let got = type_rightmost( &tree_type );
assert_eq!( got, Some( "Option".to_string() ) );