If `ty` is `Option `, return `Some(&T)`. Otherwise `None`.
(ty: &Type)
| 44 | |
| 45 | /// If `ty` is `Option<T>`, return `Some(&T)`. Otherwise `None`. |
| 46 | pub(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 | } |
no outgoing calls
no test coverage detected