Dolda2000 GitWeb
/
kaka
/
rust-sdl-test.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
93679b2
)
expect() with formatting -> unwrap_or_else()
author
Tomas Wenström
<tomas.wenstrom@gmail.com>
Sat, 2 Jan 2021 18:00:18 +0000
(19:00 +0100)
committer
Tomas Wenström
<tomas.wenstrom@gmail.com>
Sat, 2 Jan 2021 18:02:10 +0000
(19:02 +0100)
Because with expect() the formatting will always be called, even when there is a value.
src/sprites.rs
patch
|
blob
|
blame
|
history
diff --git
a/src/sprites.rs
b/src/sprites.rs
index
57fc0a4
..
0de3468
100644
(file)
--- 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
))
}
}