From fc814a29911026a1e7fc987f65204177fb5e6e9c Mon Sep 17 00:00:00 2001 From: Jiang Liu Date: Tue, 28 Mar 2023 11:19:13 +0800 Subject: [PATCH] nydus: fix a possible panic caused by SubCmdArgs::is_present() Fix a possible panic caused by SubCmdArgs::is_present(). Signed-off-by: Jiang Liu --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 8b49a92156b..f8a805464bb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,7 +40,8 @@ impl<'a> ServiceArgs for SubCmdArgs<'a> { } fn is_present(&self, key: &str) -> bool { - self.subargs.get_flag(key) || self.args.get_flag(key) + matches!(self.subargs.try_get_one::(key), Ok(Some(true))) + || matches!(self.args.try_get_one::(key), Ok(Some(true))) } }