From 8aaa43248a5dbe3c1f8369aebffd51202a505e22 Mon Sep 17 00:00:00 2001 From: Chrislearn Young Date: Tue, 30 Jul 2024 06:28:56 +0800 Subject: [PATCH] Minor code optimization --- crates/core/src/routing/filters/path.rs | 4 ++-- crates/oapi/src/lib.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/core/src/routing/filters/path.rs b/crates/core/src/routing/filters/path.rs index 6b0559132..98331918c 100644 --- a/crates/core/src/routing/filters/path.rs +++ b/crates/core/src/routing/filters/path.rs @@ -759,8 +759,8 @@ impl PathParser { let mut scaned = self.scan_wisps()?; if scaned.len() > 1 { wisps.push(CombWisp(scaned).into()); - } else if !scaned.is_empty() { - wisps.push(scaned.pop().expect("scan parts is empty")); + } else if let Some(wisp) = scaned.pop() { + wisps.push(wisp); } else { return Err("scan parts is empty".to_owned()); } diff --git a/crates/oapi/src/lib.rs b/crates/oapi/src/lib.rs index 2068ac922..9222d0fd4 100644 --- a/crates/oapi/src/lib.rs +++ b/crates/oapi/src/lib.rs @@ -416,9 +416,11 @@ impl ToSchema for serde_json::Map { /// static METADATA: Metadata = Metadata::new(""); /// &METADATA /// } +/// #[allow(refining_impl_trait)] /// async fn extract(req: &'ex mut Request) -> Result { /// salvo_core::serde::from_request(req, Self::metadata()).await /// } +/// #[allow(refining_impl_trait)] /// async fn extract_with_arg(req: &'ex mut Request, _arg: &str) -> Result { /// Self::extract(req).await /// }