Skip to content

Commit 8bebe1c

Browse files
committed
ember_html: Simplify extract_crate_name() fn by using ? operator
1 parent 157b816 commit 8bebe1c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/middleware/ember_html.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,10 @@ pub async fn serve_html(state: AppState, request: Request, next: Next) -> Respon
114114
/// prefix, and returning the firsts path segment from the result.
115115
/// Returns `None` if the path was not prefixed with [`PATH_PREFIX_CRATES`].
116116
fn extract_crate_name(path: &str) -> Option<&str> {
117-
path.strip_prefix(PATH_PREFIX_CRATES).and_then(|suffix| {
118-
let len = suffix.find('/').unwrap_or(suffix.len());
119-
let krate = &suffix[..len];
120-
krate.is_empty().not().then_some(krate)
121-
})
117+
let suffix = path.strip_prefix(PATH_PREFIX_CRATES)?;
118+
let len = suffix.find('/').unwrap_or(suffix.len());
119+
let krate = &suffix[..len];
120+
krate.is_empty().not().then_some(krate)
122121
}
123122

124123
/// Come up with an Open Graph image URL. In case a crate page is requested,

0 commit comments

Comments
 (0)