pub fn from_ref(ty: &Type) -> Result<&Type>Expand description
Extracts a &Type T from an Option<T>
§Errors
Returns an error if the given type is not an Option<T>. For more information, see the module-level documentation
§Example
use darling::util::extract_option;
use quote::ToTokens;
use syn::Type;
let ty: Type = syn::parse_str("::std::option::Option<String>")?;
let result = extract_option::from_ref(&ty)?;
let result = result.into_token_stream().to_string();
assert_eq!(result, "String");