oops, fix option.expect() and use it in libstd/map.rs
This commit is contained in:
@@ -136,7 +136,7 @@ impl extensions<T: copy> for option<T> {
|
|||||||
|
|
||||||
Fails if the value equals `none`
|
Fails if the value equals `none`
|
||||||
"]
|
"]
|
||||||
pure fn expect<T: copy>(reason: str) -> T { expect(self, reason) }
|
pure fn expect(reason: str) -> T { expect(self, reason) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -232,11 +232,11 @@ mod chained {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get(k: K) -> V {
|
fn get(k: K) -> V {
|
||||||
option::get(self.find(k))
|
self.find(k).expect("Key not found in table")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn [](k: K) -> V {
|
fn [](k: K) -> V {
|
||||||
option::get(self.find(k))
|
self.get(k)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remove(k: K) -> option<V> {
|
fn remove(k: K) -> option<V> {
|
||||||
|
|||||||
Reference in New Issue
Block a user