From 3118d31b8c83343ac4dc990ae1bbdc59aa62f103 Mon Sep 17 00:00:00 2001 From: Yuyuan Yuan Date: Tue, 28 May 2024 21:12:46 +0800 Subject: [PATCH] fix: format the error message in `ZRuntime` expect (#1049) * fix: format the error message in `ZRuntime` expect * fix(clippy): replace `expect` by `unwrap_or_else` --- commons/zenoh-runtime/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/commons/zenoh-runtime/src/lib.rs b/commons/zenoh-runtime/src/lib.rs index 2023c63bb3..7c28218a5f 100644 --- a/commons/zenoh-runtime/src/lib.rs +++ b/commons/zenoh-runtime/src/lib.rs @@ -177,8 +177,11 @@ impl ZRuntimePool { self.0 .get(&zrt) - .expect("The hashmap should contains {zrt} after initialization") - .get_or_init(|| zrt.init().expect("Failed to init {zrt}")) + .unwrap_or_else(|| panic!("The hashmap should contains {zrt} after initialization")) + .get_or_init(|| { + zrt.init() + .unwrap_or_else(|_| panic!("Failed to init {zrt}")) + }) .handle() } }