Skip to content

Commit

Permalink
early return from option result
Browse files Browse the repository at this point in the history
  • Loading branch information
ririsoft authored and abonander committed Aug 26, 2020
1 parent 6f536cc commit e8aca92
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,10 +401,7 @@ pub fn get_mime_extensions_str(mut mime_str: &str) -> Option<&'static [&'static
}

let (top, sub) = {
let split_idx = match mime_str.find('/') {
Some(idx) => idx,
None => return None,
};
let split_idx = mime_str.find('/')?;
(&mime_str[..split_idx], &mime_str[split_idx + 1..])
};

Expand Down Expand Up @@ -442,7 +439,6 @@ mod tests {
use std::fmt::Debug;
use std::path::Path;


#[test]
fn check_type_bounds() {
fn assert_type_bounds<T: Clone + Debug + Send + Sync + 'static>() {}
Expand Down Expand Up @@ -474,7 +470,9 @@ mod tests {
"image/gif".to_string()
);
assert_eq!(
from_path("/path/to/file.gif").first_or_octet_stream().to_string(),
from_path("/path/to/file.gif")
.first_or_octet_stream()
.to_string(),
"image/gif".to_string()
);
}
Expand All @@ -501,7 +499,9 @@ mod tests {
#[test]
fn test_are_mime_types_parseable() {
for (_, mimes) in MIME_TYPES {
mimes.iter().for_each(|s| { expect_mime(s); });
mimes.iter().for_each(|s| {
expect_mime(s);
});
}
}

Expand Down

0 comments on commit e8aca92

Please sign in to comment.