MCPcopy Create free account
hub / github.com/biblius/validify / try_extract_option

Function try_extract_option

validify_derive/src/fields.rs:447–471  ·  view source on GitHub ↗
(ty: &syn::Type)

Source from the content-addressed store, hash-verified

445}
446
447fn try_extract_option(ty: &syn::Type) -> Option<&syn::Type> {
448 let syn::Type::Path(p) = ty else {
449 return None;
450 };
451
452 // Always check the last arg such as in `std::vec::Vec`
453 let seg = p.path.segments.last()?;
454
455 if &seg.ident != "Option" {
456 return None;
457 }
458
459 let syn::PathArguments::AngleBracketed(ref ab) = seg.arguments else {
460 return None;
461 };
462
463 let Some(arg) = ab.args.last() else {
464 return None;
465 };
466
467 match arg {
468 syn::GenericArgument::Type(ty) => Some(ty),
469 _ => None,
470 }
471}

Callers 5

is_referenceFunction · 0.85
is_listFunction · 0.85
is_mapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected