style: Use the ? operator for Option

This commit is contained in:
Matt Brubeck 2017-12-08 16:53:17 -08:00
parent c52d347022
commit 3005a26daf
13 changed files with 47 additions and 129 deletions

View file

@ -145,10 +145,7 @@ fn to_css_identifier(mut camel_case: &str) -> String {
/// Given "FooBar", returns "Foo" and sets `camel_case` to "Bar".
fn split_camel_segment<'input>(camel_case: &mut &'input str) -> Option<&'input str> {
let index = match camel_case.chars().next() {
None => return None,
Some(ch) => ch.len_utf8(),
};
let index = camel_case.chars().next()?.len_utf8();
let end_position = camel_case[index..]
.find(char::is_uppercase)
.map_or(camel_case.len(), |pos| index + pos);