Created
October 19, 2022 21:11
-
-
Save CarlKCarlK/6651c8ec5892d663c1e232ba8d15a689 to your computer and use it in GitHub Desktop.
create_maybe_sub_type.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn create_maybe_sub_type(args: &PathArguments, span_range: &SpanRange) -> Option<Type> { | |
match args { | |
PathArguments::None => None, | |
PathArguments::AngleBracketed(ref args) => { | |
let arg = first_and_only(args.args.iter()).unwrap_or_else(|| { | |
abort!(span_range, "Expected at exactly one generic parameter.") | |
}); | |
if let GenericArgument::Type(sub_type2) = arg { | |
Some(sub_type2.clone()) | |
} else { | |
abort!(span_range, "Expected generic parameter to be a type.") | |
} | |
} | |
PathArguments::Parenthesized(_) => { | |
abort!(span_range, "Expected <..> generic parameter.") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment