MCPcopy Create free account
hub / github.com/csskit/csskit / option_inner

Function option_inner

crates/csskit_derives/src/field_view.rs:46–56  ·  view source on GitHub ↗

If `ty` is `Option `, return `Some(&T)`. Otherwise `None`.

(ty: &Type)

Source from the content-addressed store, hash-verified

44
45/// If `ty` is `Option<T>`, return `Some(&T)`. Otherwise `None`.
46pub(crate) fn option_inner(ty: &Type) -> Option<&Type> {
47 if let Type::Path(path) = ty
48 && let Some(seg) = path.path.segments.last()
49 && seg.ident == "Option"
50 && let PathArguments::AngleBracketed(args) = &seg.arguments
51 && let Some(GenericArgument::Type(inner)) = args.args.first()
52 {
53 return Some(inner);
54 }
55 None
56}

Callers 5

is_optionMethod · 0.85
unpack_optionMethod · 0.85
map_type_to_kindFunction · 0.85
deriveFunction · 0.85
viewsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected