stdlib: Use if/alt expressions in std::map

This commit is contained in:
Brian Anderson 2011-05-22 00:53:14 -04:00
parent f6777db615
commit 2d17d9101d

View File

@ -166,19 +166,17 @@ fn insert(&K key, &V val) -> bool {
}
fn contains_key(&K key) -> bool {
alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
case (option::some[V](_)) { ret true; }
case (_) { ret false; }
}
fail; // FIXME: remove me when exhaustiveness checking works
ret alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
case (option::some[V](_)) { true }
case (_) { false }
};
}
fn get(&K key) -> V {
alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
case (option::some[V](?val)) { ret val; }
case (_) { fail; }
}
fail; // FIXME: remove me when exhaustiveness checking works
ret alt (find_common[K, V](hasher, eqer, bkts, nbkts, key)) {
case (option::some[V](?val)) { val }
case (_) { fail }
};
}
fn find(&K key) -> option::t[V] {