From 05e9fe0591ffef5239ba164a924443ab5a6bc9ae Mon Sep 17 00:00:00 2001 From: Tim Zhang Date: Tue, 13 Oct 2020 19:28:34 +0800 Subject: [PATCH] agent: Use `?` instead of `match` when the error returns directly It's more clear and more readable. Signed-off-by: Tim Zhang --- src/agent/src/sandbox.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/agent/src/sandbox.rs b/src/agent/src/sandbox.rs index ac80f5be0f..ee5ab08f98 100644 --- a/src/agent/src/sandbox.rs +++ b/src/agent/src/sandbox.rs @@ -143,16 +143,10 @@ impl Sandbox { // It's assumed that caller is calling this method after // acquiring a lock on sandbox. pub fn unset_and_remove_sandbox_storage(&mut self, path: &str) -> Result<()> { - match self.unset_sandbox_storage(path) { - Ok(res) => { - if res { - return self.remove_sandbox_storage(path); - } - } - Err(err) => { - return Err(err); - } + if self.unset_sandbox_storage(path)? { + return self.remove_sandbox_storage(path); } + Ok(()) }