1
Fork 0

Utilize ? instead of return None.

This commit is contained in:
Corey Farwell 2018-11-20 23:01:56 -05:00
parent f32f1113c9
commit 9012af6f19
12 changed files with 26 additions and 68 deletions

View file

@ -91,10 +91,7 @@ pub fn parse_prefix<'a>(path: &'a OsStr) -> Option<Prefix> {
}
fn parse_two_comps(mut path: &[u8], f: fn(u8) -> bool) -> Option<(&[u8], &[u8])> {
let first = match path.iter().position(|x| f(*x)) {
None => return None,
Some(x) => &path[..x],
};
let first = &path[..path.iter().position(|x| f(*x))?];
path = &path[(first.len() + 1)..];
let idx = path.iter().position(|x| f(*x));
let second = &path[..idx.unwrap_or(path.len())];