]> git.lizzy.rs Git - rust.git/commitdiff
Port the stdlib to the typaram foo<T> syntax.
authorErick Tryzelaar <erick.tryzelaar@gmail.com>
Wed, 10 Aug 2011 16:27:11 +0000 (09:27 -0700)
committerGraydon Hoare <graydon@mozilla.com>
Tue, 16 Aug 2011 22:05:56 +0000 (15:05 -0700)
19 files changed:
src/lib/aio.rs
src/lib/comm.rs
src/lib/deque.rs
src/lib/ebml.rs
src/lib/either.rs
src/lib/extfmt.rs
src/lib/generic_os.rs
src/lib/getopts.rs
src/lib/io.rs
src/lib/list.rs
src/lib/map.rs
src/lib/option.rs
src/lib/posix_fs.rs
src/lib/sio.rs
src/lib/smallintmap.rs
src/lib/sort.rs
src/lib/test.rs
src/lib/ufind.rs
src/lib/vec.rs

index bb9caf05697e74f5b7ed32b33e2449668923e8fb..03953f40a4264bd6eaeeaaa63f3416c3c09bb7ce 100644 (file)
     fn aio_init();
     fn aio_run();
     fn aio_stop();
-    fn aio_connect(host: *u8, port: int, connected: &_chan[socket]);
-    fn aio_serve(host: *u8, port: int, acceptChan: &_chan[socket]) -> server;
-    fn aio_writedata(s: socket, buf: *u8, size: uint, status: &_chan[bool]);
-    fn aio_read(s: socket, reader: &_chan[[u8]]);
-    fn aio_close_server(s: server, status: &_chan[bool]);
+    fn aio_connect(host: *u8, port: int, connected: &_chan<socket>);
+    fn aio_serve(host: *u8, port: int, acceptChan: &_chan<socket>) -> server;
+    fn aio_writedata(s: socket, buf: *u8, size: uint, status: &_chan<bool>);
+    fn aio_read(s: socket, reader: &_chan<[u8]>);
+    fn aio_close_server(s: server, status: &_chan<bool>);
     fn aio_close_socket(s: socket);
     fn aio_is_null_client(s: socket) -> bool;
 }
 }
 
 tag server_event {
-    pending(_chan[_chan[socket_event]]);
+    pending(_chan<_chan<socket_event>>);
 }
 
 tag request {
     quit;
-    connect(pending_connection,_chan[socket_event]);
-    serve(net::ip_addr,int,_chan[server_event],_chan[server]);
-    write(client,[u8],_chan[bool]);
-    close_server(server, _chan[bool]);
+    connect(pending_connection,_chan<socket_event>);
+    serve(net::ip_addr,int,_chan<server_event>,_chan<server>);
+    write(client,[u8],_chan<bool>);
+    close_server(server, _chan<bool>);
     close_client(client);
 }
 
-type ctx = _chan[request];
+type ctx = _chan<request>;
 
 fn ip_to_sbuf(ip: net::ip_addr) -> *u8 {
     vec::to_ptr(str::bytes(net::format_addr(ip)))
 }
 
-fn connect_task(ip: net::ip_addr, portnum: int, evt: _chan[socket_event]) {
-    let connecter: _port[client] = mk_port();
+fn connect_task(ip: net::ip_addr, portnum: int, evt: _chan<socket_event>) {
+    let connecter: _port<client> = mk_port();
     rustrt::aio_connect(ip_to_sbuf(ip), portnum, connecter.mk_chan());
     let client = connecter.recv();
     new_client(client, evt);
 }
 
-fn new_client(client: client, evt: _chan[socket_event]) {
+fn new_client(client: client, evt: _chan<socket_event>) {
     // Start the read before notifying about the connect.  This avoids a race
     // condition where the receiver can close the socket before we start
     // reading.
-    let reader: _port[[u8]] = mk_port();
+    let reader: _port<[u8]> = mk_port();
     rustrt::aio_read(client, reader.mk_chan());
 
     send(evt, connected(client));
@@ -92,18 +92,18 @@ fn new_client(client: client, evt: _chan[socket_event]) {
     log "close message sent";
 }
 
-fn accept_task(client: client, events: _chan[server_event]) {
+fn accept_task(client: client, events: _chan<server_event>) {
     log "accept task was spawned";
-    let p: _port[_chan[socket_event]] = mk_port();
+    let p: _port<_chan<socket_event>> = mk_port();
     send(events, pending(p.mk_chan()));
     let evt = p.recv();
     new_client(client, evt);
     log "done accepting";
 }
 
-fn server_task(ip: net::ip_addr, portnum: int, events: _chan[server_event],
-               server: _chan[server]) {
-    let accepter: _port[client] = mk_port();
+fn server_task(ip: net::ip_addr, portnum: int, events: _chan<server_event>,
+               server: _chan<server>) {
+    let accepter: _port<client> = mk_port();
     send(server, rustrt::aio_serve(ip_to_sbuf(ip), portnum,
                                    accepter.mk_chan()));
 
@@ -120,9 +120,9 @@ fn server_task(ip: net::ip_addr, portnum: int, events: _chan[server_event],
     }
 }
 
-fn request_task(c: _chan[ctx]) {
+fn request_task(c: _chan<ctx>) {
     // Create a port to accept IO requests on
-    let p: _port[request] = mk_port();
+    let p: _port<request> = mk_port();
     // Hand of its channel to our spawner
     send(c, p.mk_chan());
     log "uv run task spawned";
@@ -160,7 +160,7 @@ fn request_task(c: _chan[ctx]) {
     }
 }
 
-fn iotask(c: _chan[ctx]) {
+fn iotask(c: _chan<ctx>) {
     log "io task spawned";
     // Initialize before accepting requests
     rustrt::aio_init();
@@ -178,7 +178,7 @@ fn iotask(c: _chan[ctx]) {
 }
 
 fn new() -> ctx {
-    let p: _port[ctx] = mk_port();
+    let p: _port<ctx> = mk_port();
     task::_spawn(bind iotask(p.mk_chan()));
     ret p.recv();
 }
index b359c1d885876ba38ff8a706d0d7094904971829..01da63635ea749ca11231ac135661821e7543d54 100644 (file)
@@ -59,7 +59,7 @@ fn recv() -> T {
     }
 }
 
-fn mk_port[~T]() -> _port[T] {
+fn mk_port[~T]() -> _port<T> {
     _port(@port_ptr(rustrt::new_port(sys::size_of[T]())))
 }
 
index 65cae49ab16e2a25900b399278ce27d35a40265d..c3d17314a41a95ae42fb38e65553266bfafd07d9 100644 (file)
@@ -16,8 +16,8 @@
         fn get(int) -> T ;
     };
 
-fn create[@T]() -> t[T] {
-    type cell[T] = option::t[T];
+fn create[@T]() -> t<T> {
+    type cell[T] = option::t<T>;
 
     let initial_capacity: uint = 32u; // 2^5
      /**
@@ -26,8 +26,8 @@ fn create[@T]() -> t[T] {
       */
 
 
-    fn grow[@T](nelts: uint, lo: uint, elts: &[mutable cell[T]]) ->
-       [mutable cell[T]] {
+    fn grow[@T](nelts: uint, lo: uint, elts: &[mutable cell<T>]) ->
+       [mutable cell<T>] {
         assert (nelts == vec::len(elts));
         let rv = ~[mutable];
 
@@ -42,22 +42,22 @@ fn grow[@T](nelts: uint, lo: uint, elts: &[mutable cell[T]]) ->
 
         ret rv;
     }
-    fn get[@T](elts: &[mutable cell[T]], i: uint) -> T {
+    fn get[@T](elts: &[mutable cell<T>], i: uint) -> T {
         ret alt elts.(i) { option::some(t) { t } _ { fail } };
     }
     obj deque[@T](mutable nelts: uint,
                   mutable lo: uint,
                   mutable hi: uint,
-                  mutable elts: [mutable cell[T]]) {
+                  mutable elts: [mutable cell<T>]) {
         fn size() -> uint { ret nelts; }
         fn add_front(t: &T) {
             let oldlo: uint = lo;
             if lo == 0u {
-                lo = vec::len[cell[T]](elts) - 1u;
+                lo = vec::len[cell<T>](elts) - 1u;
             } else { lo -= 1u; }
             if lo == hi {
                 elts = grow[T](nelts, oldlo, elts);
-                lo = vec::len[cell[T]](elts) - 1u;
+                lo = vec::len[cell<T>](elts) - 1u;
                 hi = nelts;
             }
             elts.(lo) = option::some[T](t);
@@ -70,7 +70,7 @@ fn add_back(t: &T) {
                 hi = nelts;
             }
             elts.(hi) = option::some[T](t);
-            hi = (hi + 1u) % vec::len[cell[T]](elts);
+            hi = (hi + 1u) % vec::len[cell<T>](elts);
             nelts += 1u;
         }
 
@@ -81,13 +81,13 @@ fn add_back(t: &T) {
         fn pop_front() -> T {
             let t: T = get[T](elts, lo);
             elts.(lo) = option::none[T];
-            lo = (lo + 1u) % vec::len[cell[T]](elts);
+            lo = (lo + 1u) % vec::len[cell<T>](elts);
             nelts -= 1u;
             ret t;
         }
         fn pop_back() -> T {
             if hi == 0u {
-                hi = vec::len[cell[T]](elts) - 1u;
+                hi = vec::len[cell<T>](elts) - 1u;
             } else { hi -= 1u; }
             let t: T = get[T](elts, hi);
             elts.(hi) = option::none[T];
@@ -97,11 +97,11 @@ fn pop_back() -> T {
         fn peek_front() -> T { ret get[T](elts, lo); }
         fn peek_back() -> T { ret get[T](elts, hi - 1u); }
         fn get(i: int) -> T {
-            let idx: uint = (lo + (i as uint)) % vec::len[cell[T]](elts);
+            let idx: uint = (lo + (i as uint)) % vec::len[cell<T>](elts);
             ret get[T](elts, idx);
         }
     }
-    let v: [mutable cell[T]] =
+    let v: [mutable cell<T>] =
         vec::init_elt_mut(option::none, initial_capacity);
     ret deque[T](0u, 0u, 0u, v);
 }
index b7603affb6ce7c3b8bc9e1afd958d09717f55f44..cd7fbf9eb3b98b2125ccc04fe2e6fbb9e76f67d9 100644 (file)
@@ -50,7 +50,7 @@ fn doc_at(data: &@[u8], start: uint) -> doc {
     ret {data: data, start: elt_size.next, end: end};
 }
 
-fn maybe_get_doc(d: doc, tg: uint) -> option::t[doc] {
+fn maybe_get_doc(d: doc, tg: uint) -> option::t<doc> {
     let pos = d.start;
     while pos < d.end {
         let elt_tag = vint_at(*d.data, pos);
index 018eee24dc639e268c631885bd1cdc0498379030..78496bec917953895a6378fa42f5944f0dd9944b 100644 (file)
@@ -6,30 +6,30 @@
 tag t[T, U] { left(T); right(U); }
 
 fn either[T, U, V](f_left: &block(&T) -> V, f_right: &block(&U) -> V,
-                   value: &t[T, U]) -> V {
+                   value: &t<T, U>) -> V {
     alt value { left(l) { f_left(l) } right(r) { f_right(r) } }
 }
 
-fn lefts[T, U](eithers: &[t[T, U]]) -> [T] {
+fn lefts[T, U](eithers: &[t<T, U>]) -> [T] {
     let result: [T] = ~[];
-    for elt: t[T, U] in eithers {
+    for elt: t<T, U> in eithers {
         alt elt { left(l) { result += ~[l] } _ {/* fallthrough */ } }
     }
     ret result;
 }
 
-fn rights[T, U](eithers: &[t[T, U]]) -> [U] {
+fn rights[T, U](eithers: &[t<T, U>]) -> [U] {
     let result: [U] = ~[];
-    for elt: t[T, U] in eithers {
+    for elt: t<T, U> in eithers {
         alt elt { right(r) { result += ~[r] } _ {/* fallthrough */ } }
     }
     ret result;
 }
 
-fn partition[T, U](eithers: &[t[T, U]]) -> {lefts: [T], rights: [U]} {
+fn partition[T, U](eithers: &[t<T, U>]) -> {lefts: [T], rights: [U]} {
     let lefts: [T] = ~[];
     let rights: [U] = ~[];
-    for elt: t[T, U] in eithers {
+    for elt: t<T, U> in eithers {
         alt elt { left(l) { lefts += ~[l] } right(r) { rights += ~[r] } }
     }
     ret {lefts: lefts, rights: rights};
index e188b74ab02bc16c89f8ba29801ef62b90520eca..11239d7ed4281190994ae103a574a02bc515f395 100644 (file)
@@ -60,7 +60,7 @@ mod ct {
 
     // A formatted conversion from an expression to a string
     type conv =
-        {param: option::t[int],
+        {param: option::t<int>,
          flags: [flag],
          width: count,
          precision: count,
@@ -105,7 +105,7 @@ fn flush_buf(buf: str, pieces: &mutable [piece]) -> str {
         ret pieces;
     }
     fn peek_num(s: str, i: uint, lim: uint) ->
-       option::t[{num: uint, next: uint}] {
+       option::t<{num: uint, next: uint}> {
         if i >= lim { ret none; }
         let c = s.(i);
         if !('0' as u8 <= c && c <= '9' as u8) { ret option::none; }
@@ -135,7 +135,7 @@ fn parse_conversion(s: str, i: uint, lim: uint, error: error_fn) ->
              next: ty.next};
     }
     fn parse_parameter(s: str, i: uint, lim: uint) ->
-       {param: option::t[int], next: uint} {
+       {param: option::t<int>, next: uint} {
         if i >= lim { ret {param: none, next: i}; }
         let num = peek_num(s, i, lim);
         ret alt num {
index bd78f0201049e2f0b8651bb5fc9ec5c720f36705..da660e34dc5629a47efdb92bb402750845082d1c 100644 (file)
@@ -3,7 +3,7 @@
 
 #[cfg(target_os = "linux")]
 #[cfg(target_os = "macos")]
-fn getenv(n: str) -> option::t[str] {
+fn getenv(n: str) -> option::t<str> {
     let s = os::libc::getenv(str::buf(n));
     ret if s as int == 0 {
             option::none[str]
@@ -19,7 +19,7 @@ fn setenv(n: str, v: str) {
 }
 
 #[cfg(target_os = "win32")]
-fn getenv(n: str) -> option::t[str] {
+fn getenv(n: str) -> option::t<str> {
     let nbuf = str::buf(n);
     let nsize = 256u;
     while true {
index f7795520ef5d93a506d3f932ae2191af5cc13c8b..eb56b44b4900173848241ae1d88f0e37c1456133 100644 (file)
@@ -75,7 +75,7 @@ fn name_str(nm: name) -> str {
     ret alt nm { short(ch) { str::from_char(ch) } long(s) { s } };
 }
 
-fn find_opt(opts: &[opt], nm: name) -> option::t[uint] {
+fn find_opt(opts: &[opt], nm: name) -> option::t<uint> {
     let i = 0u;
     let l = vec::len[opt](opts);
     while i < l { if opts.(i).name == nm { ret some[uint](i); } i += 1u; }
@@ -224,7 +224,7 @@ fn opt_strs(m: &match, nm: str) -> [str] {
     ret acc;
 }
 
-fn opt_maybe_str(m: &match, nm: str) -> option::t[str] {
+fn opt_maybe_str(m: &match, nm: str) -> option::t<str> {
     let vals = opt_vals(m, nm);
     if vec::len[optval](vals) == 0u { ret none[str]; }
     ret alt vals.(0) { val(s) { some[str](s) } _ { none[str] } };
@@ -234,7 +234,7 @@ fn opt_maybe_str(m: &match, nm: str) -> option::t[str] {
 /// Returns none if the option was not present, `def` if the option was
 /// present but no argument was provided, and the argument if the option was
 /// present and an argument was provided.
-fn opt_default(m: &match, nm: str, def: str) -> option::t[str] {
+fn opt_default(m: &match, nm: str, def: str) -> option::t<str> {
     let vals = opt_vals(m, nm);
     if vec::len[optval](vals) == 0u { ret none[str]; }
     ret alt vals.(0) { val(s) { some[str](s) } _ { some[str](def) } }
index 808c4e84c98220d2f731ba0e4c3e416f08e5b8ea..d10cb2fe33b070f4479136575b4761419d5f5f20 100644 (file)
@@ -59,7 +59,7 @@ fn convert_whence(whence: seek_style) -> int {
     os::libc::fclose(f);
 }
 
-obj FILE_buf_reader(f: os::libc::FILE, res: option::t[@FILE_res]) {
+obj FILE_buf_reader(f: os::libc::FILE, res: option::t<@FILE_res>) {
     fn read(len: uint) -> [u8] {
         let buf = ~[];
         vec::reserve[u8](buf, len);
@@ -243,7 +243,7 @@ fn string_reader(s: &str) -> reader {
         fn tell() -> uint ;
     };
 
-obj FILE_writer(f: os::libc::FILE, res: option::t[@FILE_res]) {
+obj FILE_writer(f: os::libc::FILE, res: option::t<@FILE_res>) {
     fn write(v: &[u8]) {
         let len = vec::len[u8](v);
         let vbuf = vec::to_ptr[u8](v);
@@ -262,7 +262,7 @@ fn tell() -> uint {
     os::libc::close(fd);
 }
 
-obj fd_buf_writer(fd: int, res: option::t[@fd_res]) {
+obj fd_buf_writer(fd: int, res: option::t<@fd_res>) {
     fn write(v: &[u8]) {
         let len = vec::len[u8](v);
         let count = 0u;
index cd379abd7502223ed86ee75aff005c4ff031d22a..9657a4fe451f3c95c7a4838e112a3956f25b0f8e 100644 (file)
@@ -1,9 +1,9 @@
 import option::some;
 import option::none;
 
-tag list[T] { cons(T, @list[T]); nil; }
+tag list[T] { cons(T, @list<T>); nil; }
 
-fn from_vec[@T](v: &[T]) -> list[T] {
+fn from_vec[@T](v: &[T]) -> list<T> {
     let l = nil[T];
     // FIXME: This would be faster and more space efficient if it looped over
     // a reverse vector iterator. Unfortunately generic iterators seem not to
@@ -13,7 +13,7 @@ fn from_vec[@T](v: &[T]) -> list[T] {
     ret l;
 }
 
-fn foldl[@T, @U](ls_: &list[T], u: &U, f: &block(&T, &U) -> U ) -> U {
+fn foldl[@T, @U](ls_: &list<T>, u: &U, f: &block(&T, &U) -> U ) -> U {
     let accum: U = u;
     let ls = ls_;
     while true {
@@ -25,8 +25,8 @@ fn foldl[@T, @U](ls_: &list[T], u: &U, f: &block(&T, &U) -> U ) -> U {
     ret accum;
 }
 
-fn find[@T, @U](ls_: &list[T], f: &block(&T) -> option::t[U])
-    -> option::t[U] {
+fn find[@T, @U](ls_: &list<T>, f: &block(&T) -> option::t<U>)
+    -> option::t<U> {
     let ls = ls_;
     while true {
         alt ls {
@@ -39,7 +39,7 @@ fn find[@T, @U](ls_: &list[T], f: &block(&T) -> option::t[U])
     ret none;
 }
 
-fn has[@T](ls_: &list[T], elt: &T) -> bool {
+fn has[@T](ls_: &list<T>, elt: &T) -> bool {
     let ls = ls_;
     while true {
         alt ls {
@@ -50,26 +50,26 @@ fn has[@T](ls_: &list[T], elt: &T) -> bool {
     ret false;
 }
 
-fn length[@T](ls: &list[T]) -> uint {
+fn length[@T](ls: &list<T>) -> uint {
     fn count[T](t: &T, u: &uint) -> uint { ret u + 1u; }
     ret foldl(ls, 0u, count);
 }
 
-fn cdr[@T](ls: &list[T]) -> list[T] {
+fn cdr[@T](ls: &list<T>) -> list<T> {
     alt ls {
       cons(_, tl) { ret *tl; }
       nil. { fail "list empty" }
     }
 }
 
-fn car[@T](ls: &list[T]) -> T {
+fn car[@T](ls: &list<T>) -> T {
     alt ls {
       cons(hd, _) { ret hd; }
       nil. { fail "list empty" }
     }
 }
 
-fn append[@T](l: &list[T], m: &list[T]) -> list[T] {
+fn append[@T](l: &list<T>, m: &list<T>) -> list<T> {
     alt l {
       nil. { ret m; }
       cons(x, xs) {
index 3d9c11e90612c6ce69b28bbc06586736ed08f8aa..d6135864e5b502422666c0cf7cb6d5b78f2e59e2 100644 (file)
         fn insert(&K, &V) -> bool ;
         fn contains_key(&K) -> bool ;
         fn get(&K) -> V ;
-        fn find(&K) -> option::t[V] ;
-        fn remove(&K) -> option::t[V] ;
+        fn find(&K) -> option::t<V> ;
+        fn remove(&K) -> option::t<V> ;
         fn rehash() ;
         iter items() -> @{key: K, val: V} ;
         iter keys() -> K ;
     };
-type hashset[K] = hashmap[K, ()];
+type hashset[K] = hashmap<K, ()>;
 
-fn set_add[@K](set: hashset[K], key: &K) -> bool { ret set.insert(key, ()); }
+fn set_add[@K](set: hashset<K>, key: &K) -> bool { ret set.insert(key, ()); }
 
-fn mk_hashmap[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K]) -> hashmap[K, V] {
+fn mk_hashmap[@K, @V](hasher: &hashfn<K>, eqer: &eqfn<K>) -> hashmap<K, V> {
     let initial_capacity: uint = 32u; // 2^5
 
     let load_factor: util::rational = {num: 3, den: 4};
     tag bucket[@K, @V] { nil; deleted; some(K, V); }
-    fn make_buckets[@K, @V](nbkts: uint) -> [mutable (bucket[K, V])] {
-        ret vec::init_elt_mut[bucket[K, V]](nil[K, V], nbkts);
+    fn make_buckets[@K, @V](nbkts: uint) -> [mutable (bucket<K, V>)] {
+        ret vec::init_elt_mut[bucket<K, V>](nil[K, V], nbkts);
     }
     // Derive two hash functions from the one given by taking the upper
     // half and lower half of the uint bits.  Our bucket probing
@@ -53,8 +53,8 @@ fn hash(h: uint, nbkts: uint, i: uint) -> uint {
      * will fail.
      */
 
-    fn insert_common[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K],
-                             bkts: &[mutable bucket[K, V]], nbkts: uint,
+    fn insert_common[@K, @V](hasher: &hashfn<K>, eqer: &eqfn<K>,
+                             bkts: &[mutable bucket<K, V>], nbkts: uint,
                              key: &K, val: &V) -> bool {
         let i: uint = 0u;
         let h: uint = hasher(key);
@@ -76,9 +76,9 @@ fn insert_common[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K],
         }
         fail; // full table
     }
-    fn find_common[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K],
-                           bkts: &[mutable bucket[K, V]], nbkts: uint,
-                           key: &K) -> option::t[V] {
+    fn find_common[@K, @V](hasher: &hashfn<K>, eqer: &eqfn<K>,
+                           bkts: &[mutable bucket<K, V>], nbkts: uint,
+                           key: &K) -> option::t<V> {
         let i: uint = 0u;
         let h: uint = hasher(key);
         while i < nbkts {
@@ -97,10 +97,10 @@ fn find_common[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K],
         }
         ret option::none;
     }
-    fn rehash[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K],
-                      oldbkts: &[mutable bucket[K, V]], noldbkts: uint,
-                      newbkts: &[mutable bucket[K, V]], nnewbkts: uint) {
-        for b: bucket[K, V] in oldbkts {
+    fn rehash[@K, @V](hasher: &hashfn<K>, eqer: &eqfn<K>,
+                      oldbkts: &[mutable bucket<K, V>], noldbkts: uint,
+                      newbkts: &[mutable bucket<K, V>], nnewbkts: uint) {
+        for b: bucket<K, V> in oldbkts {
             alt b {
               some(k_, v_) {
                 let k = k_;
@@ -111,9 +111,9 @@ fn rehash[@K, @V](hasher: &hashfn[K], eqer: &eqfn[K],
             }
         }
     }
-    obj hashmap[@K, @V](hasher: hashfn[K],
-                        eqer: eqfn[K],
-                        mutable bkts: [mutable bucket[K, V]],
+    obj hashmap[@K, @V](hasher: hashfn<K>,
+                        eqer: eqfn<K>,
+                        mutable bkts: [mutable bucket<K, V>],
                         mutable nbkts: uint,
                         mutable nelts: uint,
                         lf: util::rational) {
@@ -146,10 +146,10 @@ fn get(key: &K) -> V {
                   _ { fail }
                 };
         }
-        fn find(key: &K) -> option::t[V] {
+        fn find(key: &K) -> option::t<V> {
             be find_common(hasher, eqer, bkts, nbkts, key);
         }
-        fn remove(key: &K) -> option::t[V] {
+        fn remove(key: &K) -> option::t<V> {
             let i: uint = 0u;
             let h: uint = hasher(key);
             while i < nbkts {
@@ -177,12 +177,12 @@ fn rehash() {
             bkts = newbkts;
         }
         iter items() -> @{key: K, val: V} {
-            for b: bucket[K, V] in bkts {
+            for b: bucket<K, V> in bkts {
                 alt b { some(k, v) { put @{key: k, val: v}; } _ { } }
             }
         }
         iter keys() -> K {
-            for b: bucket[K, V] in bkts {
+            for b: bucket<K, V> in bkts {
                 alt b { some(k, _) { put k; } _ { } }
             }
         }
@@ -193,17 +193,17 @@ fn rehash() {
 
 // Hash map constructors for basic types
 
-fn new_str_hash[@V]() -> hashmap[str, V] {
+fn new_str_hash[@V]() -> hashmap<str, V> {
     ret mk_hashmap(str::hash, str::eq);
 }
 
-fn new_int_hash[@V]() -> hashmap[int, V] {
+fn new_int_hash[@V]() -> hashmap<int, V> {
     fn hash_int(x: &int) -> uint { ret x as uint; }
     fn eq_int(a: &int, b: &int) -> bool { ret a == b; }
     ret mk_hashmap(hash_int, eq_int);
 }
 
-fn new_uint_hash[@V]() -> hashmap[uint, V] {
+fn new_uint_hash[@V]() -> hashmap<uint, V> {
     fn hash_uint(x: &uint) -> uint { ret x; }
     fn eq_uint(a: &uint, b: &uint) -> bool { ret a == b; }
     ret mk_hashmap(hash_uint, eq_uint);
index ff2dfc71efbd407927b7924aa4349caceb95703c..e803c9fc66c66b003afb83cd1528a0a2387c54b4 100644 (file)
@@ -2,33 +2,33 @@
 
 tag t[@T] { none; some(T); }
 
-fn get[@T](opt: &t[T]) -> T {
+fn get[@T](opt: &t<T>) -> T {
     alt opt {
       some(x) { x }
       none. { fail "option none" }
     }
 }
 
-fn map[@T, @U](f: &block(&T) -> U, opt: &t[T]) -> t[U] {
+fn map[@T, @U](f: &block(&T) -> U, opt: &t<T>) -> t<U> {
     alt opt { some(x) { some(f(x)) } none. { none } }
 }
 
-fn is_none[@T](opt: &t[T]) -> bool {
+fn is_none[@T](opt: &t<T>) -> bool {
     alt opt { none. { true } some(_) { false } }
 }
 
-fn is_some[@T](opt: &t[T]) -> bool { !is_none(opt) }
+fn is_some[@T](opt: &t<T>) -> bool { !is_none(opt) }
 
-fn from_maybe[@T](def: &T, opt: &t[T]) -> T {
+fn from_maybe[@T](def: &T, opt: &t<T>) -> T {
     alt opt { some(x) { x } none. { def } }
 }
 
-fn maybe[@T, @U](def: &U, f: &block(&T) -> U, opt: &t[T]) -> U {
+fn maybe[@T, @U](def: &U, f: &block(&T) -> U, opt: &t<T>) -> U {
     alt opt { none. { def } some(t) { f(t) } }
 }
 
 // Can be defined in terms of the above when/if we have const bind.
-fn may[@T](f: &block(&T), opt: &t[T]) {
+fn may[@T](f: &block(&T), opt: &t<T>) {
     alt opt { none. {/* nothing */ } some(t) { f(t); } }
 }
 
index 1a84e0faf5a32505be3269e8a0cd31b19b6b65fa..16dacf287f6187d58b9d3f8772b9e88085d7ee13 100644 (file)
@@ -17,7 +17,7 @@ fn list_dir(path: str) -> [str] {
     /*
     auto dir = os::libc::opendir(str::buf(path));
     assert (dir as uint != 0u);
-    let vec[str] result = [];
+    let vec<str> result = [];
     while (true) {
         auto ent = os::libc::readdir(dir);
         if (ent as int == 0) {
index 7f8e56516e3ba94316e6b7fddbe80999987e5ba2..bd75efa76a5a59b8472d0cb5063e3b9b98d1b93b 100644 (file)
@@ -8,9 +8,9 @@
 
 type ctx = aio::ctx;
 type client = { ctx: ctx, client: aio::client,
-               evt: _port[aio::socket_event] };
+               evt: _port<aio::socket_event> };
 type server = { ctx: ctx, server: aio::server,
-               evt: _port[aio::server_event] };
+               evt: _port<aio::server_event> };
 
 fn new() -> ctx {
     ret aio::new();
@@ -20,7 +20,7 @@ fn destroy(ctx: ctx) {
     send(ctx, aio::quit);
 }
 
-fn make_socket(ctx: ctx, p: _port[aio::socket_event]) -> client {
+fn make_socket(ctx: ctx, p: _port<aio::socket_event>) -> client {
     let evt: aio::socket_event = p.recv();
     alt evt {
       aio::connected(client) {
@@ -31,7 +31,7 @@ fn make_socket(ctx: ctx, p: _port[aio::socket_event]) -> client {
 }
 
 fn connect_to(ctx: ctx, ip: net::ip_addr, portnum: int) -> client {
-    let p: _port[aio::socket_event] = mk_port();
+    let p: _port<aio::socket_event> = mk_port();
     send(ctx, aio::connect(aio::remote(ip, portnum), p.mk_chan()));
     ret make_socket(ctx, p);
 }
@@ -48,8 +48,8 @@ fn read(c: client) -> [u8] {
 }
 
 fn create_server(ctx: ctx, ip: net::ip_addr, portnum: int) -> server {
-    let evt: _port[aio::server_event] = mk_port();
-    let p: _port[aio::server] = mk_port();
+    let evt: _port<aio::server_event> = mk_port();
+    let p: _port<aio::server> = mk_port();
     send(ctx, aio::serve(ip, portnum,
                          evt.mk_chan(), p.mk_chan()));
     let srv: aio::server = p.recv();
@@ -60,7 +60,7 @@ fn accept_from(server: server) -> client {
     let evt: aio::server_event = server.evt.recv();
     alt evt {
       aio::pending(callback) {
-        let p: _port[aio::socket_event] = mk_port();
+        let p: _port<aio::socket_event> = mk_port();
         send(callback, p.mk_chan());
         ret make_socket(server.ctx, p);
       }
@@ -68,14 +68,14 @@ fn accept_from(server: server) -> client {
 }
 
 fn write_data(c: client, data: [u8]) -> bool {
-    let p: _port[bool] = mk_port();
+    let p: _port<bool> = mk_port();
     send(c.ctx, aio::write(c.client, data, p.mk_chan()));
     ret p.recv();
 }
 
 fn close_server(server: server) {
     // TODO: make this unit once we learn to send those from native code
-    let p: _port[bool] = mk_port();
+    let p: _port<bool> = mk_port();
     send(server.ctx, aio::close_server(server.server, p.mk_chan()));
     log "Waiting for close";
     p.recv();
index c3da9dfa3663c40d8e1a866f3864fb9d9438212e..682cc47d647d31838ae4fc6922ea8d26f788406f 100644 (file)
@@ -7,38 +7,38 @@
 
 // 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] {
-    let v: [mutable option::t[T]] = ~[mutable];
+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) {
-    vec::grow_set[option::t[T]](m.v, key, none[T], some[T](val));
+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] {
-    if key < vec::len[option::t[T]](m.v) { ret m.v.(key); }
+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) {
-    m.v = vec::slice_mut[option::t[T]](m.v, 0u, len);
+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 {
-    ret vec::len[option::t[T]](m.v);
+fn max_key[T](m: &smallintmap<T>) -> uint {
+    ret vec::len[option::t<T>](m.v);
 }
 
index 0aa8c5b6d13599d7f793aecbae508ac55d9a6b80..24f06f550997a8e699780d7d991b01808a4bb3f2 100644 (file)
@@ -8,8 +8,8 @@
 
 type lteq[T] = block(&T, &T) -> bool ;
 
-fn merge_sort[@T](le: &lteq[T], v: &[T]) -> [T] {
-    fn merge[@T](le: &lteq[T], a: &[T], b: &[T]) -> [T] {
+fn merge_sort[@T](le: &lteq<T>, v: &[T]) -> [T] {
+    fn merge[@T](le: &lteq<T>, a: &[T], b: &[T]) -> [T] {
         let rs: [T] = ~[];
         let a_len: uint = len[T](a);
         let a_ix: uint = 0u;
@@ -39,7 +39,7 @@ fn swap[@T](arr: &[mutable T], x: uint, y: uint) {
     arr.(y) = a;
 }
 
-fn part[@T](compare_func: &lteq[T], arr: &[mutable T], left: uint,
+fn part[@T](compare_func: &lteq<T>, arr: &[mutable T], left: uint,
             right: uint, pivot: uint) -> uint {
     let pivot_value = arr.(pivot);
     swap[T](arr, pivot, right);
@@ -56,7 +56,7 @@ fn part[@T](compare_func: &lteq[T], arr: &[mutable T], left: uint,
     ret storage_index;
 }
 
-fn qsort[@T](compare_func: &lteq[T], arr: &[mutable T], left: uint,
+fn qsort[@T](compare_func: &lteq<T>, arr: &[mutable T], left: uint,
              right: uint) {
     if right > left {
         let pivot = (left + right) / 2u;
@@ -69,7 +69,7 @@ fn qsort[@T](compare_func: &lteq[T], arr: &[mutable T], left: uint,
     }
 }
 
-fn quick_sort[@T](compare_func: &lteq[T], arr: &[mutable T]) {
+fn quick_sort[@T](compare_func: &lteq<T>, arr: &[mutable T]) {
     if len[T](arr) == 0u { ret; }
     qsort[T](compare_func, arr, 0u, len[T](arr) - 1u);
 }
@@ -79,7 +79,7 @@ fn quick_sort[@T](compare_func: &lteq[T], arr: &[mutable T]) {
 // http://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pdf
 // According to these slides this is the algorithm of choice for
 // 'randomly ordered keys, abstract compare' & 'small number of key values'
-fn qsort3[@T](compare_func_lt: &lteq[T], compare_func_eq: &lteq[T],
+fn qsort3[@T](compare_func_lt: &lteq<T>, compare_func_eq: &lteq<T>,
               arr: &[mutable T], left: int, right: int) {
     if right <= left { ret; }
     let v: T = arr.(right);
@@ -127,7 +127,7 @@ fn qsort3[@T](compare_func_lt: &lteq[T], compare_func_eq: &lteq[T],
     qsort3[T](compare_func_lt, compare_func_eq, arr, i, right);
 }
 
-fn quick_sort3[@T](compare_func_lt: &lteq[T], compare_func_eq: &lteq[T],
+fn quick_sort3[@T](compare_func_lt: &lteq<T>, compare_func_eq: &lteq<T>,
                    arr: &[mutable T]) {
     if len[T](arr) == 0u { ret; }
     qsort3[T](compare_func_lt, compare_func_eq, arr, 0,
index 46f166995d6bdf2897ec5d0a741ce65696ea0049..9cde409df9346eaaa401653d16b3d32eea7089b8 100644 (file)
@@ -59,13 +59,13 @@ fn test_main_ivec(args: &[str], tests: &[test_desc]) {
     if !run_tests_console(opts, tests) { fail "Some tests failed"; }
 }
 
-fn test_main(args: &vec[str], tests: &[test_desc]) {
+fn test_main(args: &vec<str>, tests: &[test_desc]) {
     test_main_ivec(vec::from_vec(args), tests);
 }
 
-type test_opts = {filter: option::t[str], run_ignored: bool};
+type test_opts = {filter: option::t<str>, run_ignored: bool};
 
-type opt_res = either::t[test_opts, str];
+type opt_res = either::t<test_opts, str>;
 
 // Parses command line arguments into test options
 fn parse_opts(args: &[str]) : vec::is_not_empty(args) -> opt_res {
@@ -268,7 +268,7 @@ fn filter_tests(opts: &test_opts, tests: &[test_desc]) -> [test_desc] {
 
             let filter =
                 bind fn (test: &test_desc, filter_str: str) ->
-                        option::t[test_desc] {
+                        option::t<test_desc> {
                          if str::find(test.name, filter_str) >= 0 {
                              ret option::some(test);
                          } else { ret option::none; }
@@ -284,7 +284,7 @@ fn filter_tests(opts: &test_opts, tests: &[test_desc]) -> [test_desc] {
             filtered
         } else {
             let filter =
-                fn (test: &test_desc) -> option::t[test_desc] {
+                fn (test: &test_desc) -> option::t<test_desc> {
                     if test.ignore {
                         ret option::some({name: test.name,
                                           fn: test.fn,
index ecaec5357977de9e249cbab36078bcf6debfeb3f..eb52027d4b8575fcb67c821b88a4923ba4f02b44 100644 (file)
@@ -6,7 +6,7 @@
 // A very naive implementation of union-find with unsigned integer nodes.
 // Maintains the invariant that the root of a node is always equal to or less
 // than the node itself.
-type node = option::t[uint];
+type node = option::t<uint>;
 
 type ufind = {mutable nodes: [mutable node]};
 
index be2a1eeea6ffeb93bc51da675b5108b2fb2609d9..f82eec559ed88bb3373af5980378c3608e5f77b8 100644 (file)
@@ -17,7 +17,7 @@ fn ivec_copy_from_buf_shared[T](v: &mutable [mutable? T], ptr: *T,
                                     count: uint);
 }
 
-fn from_vec[@T](v: &vec[mutable? T]) -> [T] {
+fn from_vec[@T](v: &vec<mutable? T>) -> [T] {
     let iv = ~[];
     for e in v {
         iv += ~[e];
@@ -38,7 +38,7 @@ fn reserve[@T](v: &mutable [mutable? T], n: uint) {
 
 type init_op[T] = fn(uint) -> T ;
 
-fn init_fn[@T](op: &init_op[T], n_elts: uint) -> [T] {
+fn init_fn[@T](op: &init_op<T>, n_elts: uint) -> [T] {
     let v = ~[];
     reserve(v, n_elts);
     let i: uint = 0u;
@@ -47,7 +47,7 @@ fn init_fn[@T](op: &init_op[T], n_elts: uint) -> [T] {
 }
 
 // TODO: Remove me once we have slots.
-fn init_fn_mut[@T](op: &init_op[T], n_elts: uint) -> [mutable T] {
+fn init_fn_mut[@T](op: &init_op<T>, n_elts: uint) -> [mutable T] {
     let v = ~[mutable];
     reserve(v, n_elts);
     let i: uint = 0u;
@@ -104,7 +104,7 @@ fn tail[@T](v: &[mutable? T]) : is_not_empty(v) -> [mutable? T] {
 }
 
 /// Returns the last element of `v`.
-fn last[@T](v: &[mutable? T]) -> option::t[T] {
+fn last[@T](v: &[mutable? T]) -> option::t<T> {
     if len(v) == 0u { ret none; }
     ret some(v.(len(v) - 1u));
 }
@@ -210,7 +210,7 @@ fn map2[@T, @U, @V](f: &block(&T, &U) -> V, v0: &[T], v1: &[U])
     ret u;
 }
 
-fn filter_map[@T, @U](f: &block(&T) -> option::t[U],
+fn filter_map[@T, @U](f: &block(&T) -> option::t<U>,
                       v: &[mutable? T]) -> [U] {
     let result = ~[];
     for elem: T in v {
@@ -252,18 +252,18 @@ fn count[T](x: &T, v: &[mutable? T]) -> uint {
     ret cnt;
 }
 
-fn find[@T](f: &block(&T) -> bool , v: &[T]) -> option::t[T] {
+fn find[@T](f: &block(&T) -> bool, v: &[T]) -> option::t<T> {
     for elt: T in v { if f(elt) { ret some(elt); } }
     ret none;
 }
 
-fn position[@T](x: &T, v: &[T]) -> option::t[uint] {
+fn position[@T](x: &T, v: &[T]) -> option::t<uint> {
     let i: uint = 0u;
     while i < len(v) { if x == v.(i) { ret some[uint](i); } i += 1u; }
     ret none[uint];
 }
 
-fn position_pred[T](f: fn(&T) -> bool , v: &[T]) -> option::t[uint] {
+fn position_pred[T](f: fn(&T) -> bool, v: &[T]) -> option::t<uint> {
     let i: uint = 0u;
     while i < len(v) { if f(v.(i)) { ret some[uint](i); } i += 1u; }
     ret none[uint];