Function type_parameters

Source
pub fn type_parameters<R>(ty: &Type, range: R) -> Vec<&Type>
where R: Into<Interval>,
Expand description

Return the specified number of parameters of the type.

Good to getting i32 from core::option::Option< i32 > or alloc::vec::Vec< i32 >

ยงSample

use proc_macro_tools::*;

let code = qt!( core::option::Option< i8, i16, i32, i64 > );
let tree_type = syn::parse2::< syn::Type >( code ).unwrap();
let got = type_parameters( &tree_type, 0..=2 );
got.iter().for_each( | e | println!( "{}", qt!( #e ) ) );
// < i8
// < i16
// < i32