Function macro_tools::typ::parameter_first
source · pub fn parameter_first(ty: &Type) -> Result<&Type>
Expand description
Extracts the first generic parameter from a given syn::Type
if any exists.
This function is designed to analyze a type and retrieve its first generic parameter. It is particularly useful when working with complex types in macro expansions and needs to extract specific type information for further processing.
§Example
let type_string = "Result< Option< i32 >, Error >";
let parsed_type : syn::Type = syn::parse_str( type_string ).expect( "Type should parse correctly" );
let first_param = macro_tools::typ::parameter_first( &parsed_type ).expect( "Should have at least one parameter" );
// Option< i32 >