Function wproc_macro::type_rightmost[][src]

pub fn type_rightmost(ty: &Type) -> Option<String>
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 wproc_macro::*;
use quote::quote;

let code = quote!( 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() ) );