diff options
| author | Erick Tryzelaar <erick.tryzelaar@gmail.com> | 2011-08-12 06:37:10 -0700 |
|---|---|---|
| committer | Graydon Hoare <graydon@mozilla.com> | 2011-08-16 15:05:56 -0700 |
| commit | 4c9049c50c5c32f556eaefbcc50209ef8ee353d0 (patch) | |
| tree | bfb83e800b3ebbba65beb080dad463f72da4ac73 /src/lib/smallintmap.rs | |
| parent | 21f46a1655f2a026546792546b07dec9e039ec54 (diff) | |
| download | rust-4c9049c50c5c32f556eaefbcc50209ef8ee353d0.tar.gz rust-4c9049c50c5c32f556eaefbcc50209ef8ee353d0.zip | |
Port the stdlib to the decl foo<T> syntax.
Diffstat (limited to 'src/lib/smallintmap.rs')
| -rw-r--r-- | src/lib/smallintmap.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/smallintmap.rs b/src/lib/smallintmap.rs index 682cc47d647..6d2c6e715c1 100644 --- a/src/lib/smallintmap.rs +++ b/src/lib/smallintmap.rs @@ -7,38 +7,38 @@ import option::some; // FIXME: Should not be @; there's a bug somewhere in rustc that requires this // to be. -type smallintmap[T] = @{mutable v: [mutable option::t<T>]}; +type smallintmap<T> = @{mutable v: [mutable option::t<T>]}; -fn mk[@T]() -> smallintmap<T> { +fn mk<@T>() -> smallintmap<T> { let v: [mutable option::t<T>] = ~[mutable]; ret @{mutable v: v}; } -fn insert[@T](m: &smallintmap<T>, key: uint, val: &T) { +fn insert<@T>(m: &smallintmap<T>, key: uint, val: &T) { vec::grow_set[option::t<T>](m.v, key, none[T], some[T](val)); } -fn find[@T](m: &smallintmap<T>, key: uint) -> option::t<T> { +fn find<@T>(m: &smallintmap<T>, key: uint) -> option::t<T> { if key < vec::len[option::t<T>](m.v) { ret m.v.(key); } ret none[T]; } -fn get[@T](m: &smallintmap<T>, key: uint) -> T { +fn get<@T>(m: &smallintmap<T>, key: uint) -> T { alt find[T](m, key) { none[T]. { log_err "smallintmap::get(): key not present"; fail; } some[T](v) { ret v; } } } -fn contains_key[@T](m: &smallintmap<T>, key: uint) -> bool { +fn contains_key<@T>(m: &smallintmap<T>, key: uint) -> bool { ret !option::is_none(find[T](m, key)); } -fn truncate[@T](m: &smallintmap<T>, len: uint) { +fn truncate<@T>(m: &smallintmap<T>, len: uint) { m.v = vec::slice_mut[option::t<T>](m.v, 0u, len); } -fn max_key[T](m: &smallintmap<T>) -> uint { +fn max_key<T>(m: &smallintmap<T>) -> uint { ret vec::len[option::t<T>](m.v); } |
