From 55eb2b7d14ed296940a375f1561209ec78ac5b46 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Sat, 2 Jan 2021 19:00:18 +0100 Subject: [PATCH] expect() with formatting -> unwrap_or_else() Because with expect() the formatting will always be called, even when there is a value. --- src/sprites.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sprites.rs b/src/sprites.rs index 57fc0a4..0de3468 100644 --- a/src/sprites.rs +++ b/src/sprites.rs @@ -23,6 +23,6 @@ impl SpriteManager { } pub fn get(&self, name: &str) -> &Texture { - self.textures.get(name).expect(format!("The sprite '{}' was not found", name).as_str()) + self.textures.get(name).unwrap_or_else(|| panic!("The sprite '{}' was not found", name)) } } -- 2.11.0