mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
improve failure message when key is not present
This commit is contained in:
+4
-1
@@ -237,7 +237,10 @@ fn find(k: K) -> option<V> {
|
||||
}
|
||||
|
||||
fn get(k: K) -> V {
|
||||
self.find(k).expect(~"Key not found in table")
|
||||
alt self.find(k) {
|
||||
some(v) => {v}
|
||||
none => {fail #fmt["Key not found in table: %?", k]}
|
||||
}
|
||||
}
|
||||
|
||||
fn [](k: K) -> V {
|
||||
|
||||
Reference in New Issue
Block a user