about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorErick Tryzelaar <erick.tryzelaar@gmail.com>2013-03-02 07:12:53 -0800
committerErick Tryzelaar <erick.tryzelaar@gmail.com>2013-03-02 07:12:53 -0800
commit5515fd5c8cf65a8eebd43ddb0de6ff920a509ece (patch)
tree4e3d85a43f684fd9d3b2e80a6a9178f90e63d7ce /src/libstd
parentaa3505d8ff043f0c1da62de4f517eed6defb6187 (diff)
parent2304fe6208404ce952aaa37e7634db570ff71f6c (diff)
downloadrust-5515fd5c8cf65a8eebd43ddb0de6ff920a509ece.tar.gz
rust-5515fd5c8cf65a8eebd43ddb0de6ff920a509ece.zip
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/arc.rs6
-rw-r--r--src/libstd/ebml.rs4
-rw-r--r--src/libstd/net_tcp.rs152
-rw-r--r--src/libstd/sync.rs6
-rw-r--r--src/libstd/treemap.rs167
-rw-r--r--src/libstd/uv_global_loop.rs4
6 files changed, 172 insertions, 167 deletions
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs
index 69c5026cbd1..ea59d6a54c6 100644
--- a/src/libstd/arc.rs
+++ b/src/libstd/arc.rs
@@ -20,9 +20,9 @@ use core::cast;
 use core::cell::Cell;
 use core::pipes;
 use core::prelude::*;
-use core::private::{SharedMutableState, shared_mutable_state};
-use core::private::{clone_shared_mutable_state};
-use core::private::{get_shared_mutable_state, get_shared_immutable_state};
+use core::unstable::{SharedMutableState, shared_mutable_state};
+use core::unstable::{clone_shared_mutable_state};
+use core::unstable::{get_shared_mutable_state, get_shared_immutable_state};
 use core::ptr;
 use core::task;
 use core::util;
diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs
index 7d04f676079..cbe0580a609 100644
--- a/src/libstd/ebml.rs
+++ b/src/libstd/ebml.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -219,7 +219,7 @@ pub mod reader {
     }
 
     pub fn Decoder(d: Doc) -> Decoder {
-        Decoder { mut parent: d, mut pos: d.start }
+        Decoder { parent: d, pos: d.start }
     }
 
     priv impl Decoder {
diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs
index dcbf7e60d89..4266cab0a05 100644
--- a/src/libstd/net_tcp.rs
+++ b/src/libstd/net_tcp.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -43,7 +43,7 @@ extern mod rustrt {
 /**
  * Encapsulates an open TCP/IP connection through libuv
  *
- * `tcp_socket` is non-copyable/sendable and automagically handles closing the
+ * `TcpSocket` is non-copyable/sendable and automagically handles closing the
  * underlying libuv data structures when it goes out of scope. This is the
  * data structure that is used for read/write operations over a TCP stream.
  */
@@ -66,10 +66,10 @@ pub fn TcpSocket(socket_data: @TcpSocketData) -> TcpSocket {
 }
 
 /**
- * A buffered wrapper for `net::tcp::tcp_socket`
+ * A buffered wrapper for `net::tcp::TcpSocket`
  *
  * It is created with a call to `net::tcp::socket_buf()` and has impls that
- * satisfy both the `io::reader` and `io::writer` traits.
+ * satisfy both the `io::Reader` and `io::Writer` traits.
  */
 pub struct TcpSocketBuf {
     data: @TcpBufferedSocketData,
@@ -89,7 +89,7 @@ pub struct TcpErrData {
     err_msg: ~str,
 }
 
-/// Details returned as part of a `result::err` result from `tcp::listen`
+/// Details returned as part of a `Result::Err` result from `tcp::listen`
 pub enum TcpListenErrData {
     /**
      * Some unplanned-for error. The first and second fields correspond
@@ -116,7 +116,7 @@ pub enum TcpListenErrData {
      */
     AccessDenied
 }
-/// Details returned as part of a `result::err` result from `tcp::connect`
+/// Details returned as part of a `Result::Err` result from `tcp::connect`
 pub enum TcpConnectErrData {
     /**
      * Some unplanned-for error. The first and second fields correspond
@@ -139,9 +139,9 @@ pub enum TcpConnectErrData {
  * # Returns
  *
  * A `result` that, if the operation succeeds, contains a
- * `net::net::tcp_socket` that can be used to send and receive data to/from
+ * `net::net::TcpSocket` that can be used to send and receive data to/from
  * the remote host. In the event of failure, a
- * `net::tcp::tcp_connect_err_data` instance will be returned
+ * `net::tcp::TcpConnectErrData` instance will be returned
  */
 pub fn connect(input_ip: ip::IpAddr, port: uint,
                iotask: &IoTask)
@@ -288,14 +288,14 @@ pub fn connect(input_ip: ip::IpAddr, port: uint,
  *
  * # Arguments
  *
- * * sock - a `tcp_socket` to write to
+ * * sock - a `TcpSocket` to write to
  * * raw_write_data - a vector of `~[u8]` that will be written to the stream.
  * This value must remain valid for the duration of the `write` call
  *
  * # Returns
  *
- * A `result` object with a `nil` value as the `ok` variant, or a
- * `tcp_err_data` value as the `err` variant
+ * A `Result` object with a `()` value as the `Ok` variant, or a
+ * `TcpErrData` value as the `Err` variant
  */
 pub fn write(sock: &TcpSocket, raw_write_data: ~[u8])
     -> result::Result<(), TcpErrData> {
@@ -306,7 +306,7 @@ pub fn write(sock: &TcpSocket, raw_write_data: ~[u8])
 }
 
 /**
- * Write binary data to tcp stream; Returns a `future::future` value
+ * Write binary data to tcp stream; Returns a `future::Future` value
  * immediately
  *
  * # Safety
@@ -314,27 +314,27 @@ pub fn write(sock: &TcpSocket, raw_write_data: ~[u8])
  * This function can produce unsafe results if:
  *
  * 1. the call to `write_future` is made
- * 2. the `future::future` value returned is never resolved via
- * `future::get`
- * 3. and then the `tcp_socket` passed in to `write_future` leaves
+ * 2. the `future::Future` value returned is never resolved via
+ * `Future::get`
+ * 3. and then the `TcpSocket` passed in to `write_future` leaves
  * scope and is destructed before the task that runs the libuv write
  * operation completes.
  *
  * As such: If using `write_future`, always be sure to resolve the returned
- * `future` so as to ensure libuv doesn't try to access a released write
+ * `Future` so as to ensure libuv doesn't try to access a released write
  * handle. Otherwise, use the blocking `tcp::write` function instead.
  *
  * # Arguments
  *
- * * sock - a `tcp_socket` to write to
+ * * sock - a `TcpSocket` to write to
  * * raw_write_data - a vector of `~[u8]` that will be written to the stream.
  * This value must remain valid for the duration of the `write` call
  *
  * # Returns
  *
- * A `future` value that, once the `write` operation completes, resolves to a
- * `result` object with a `nil` value as the `ok` variant, or a `tcp_err_data`
- * value as the `err` variant
+ * A `Future` value that, once the `write` operation completes, resolves to a
+ * `Result` object with a `nil` value as the `Ok` variant, or a `TcpErrData`
+ * value as the `Err` variant
  */
 pub fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
     -> future::Future<result::Result<(), TcpErrData>> {
@@ -353,14 +353,14 @@ pub fn write_future(sock: &TcpSocket, raw_write_data: ~[u8])
  *
  * # Arguments
  *
- * * sock -- a `net::tcp::tcp_socket` for the connection to read from
+ * * sock -- a `net::tcp::TcpSocket` for the connection to read from
  *
  * # Returns
  *
- * * A `result` instance that will either contain a
- * `core::comm::port<tcp_read_result>` that the user can read (and
- * optionally, loop on) from until `read_stop` is called, or a
- * `tcp_err_data` record
+ * * A `Result` instance that will either contain a
+ * `core::comm::Port<Result<~[u8], TcpErrData>>` that the user can read
+ * (and * optionally, loop on) from until `read_stop` is called, or a
+ * `TcpErrData` record
  */
 pub fn read_start(sock: &TcpSocket)
     -> result::Result<@Port<
@@ -376,7 +376,7 @@ pub fn read_start(sock: &TcpSocket)
  *
  * # Arguments
  *
- * * `sock` - a `net::tcp::tcp_socket` that you wish to stop reading on
+ * * `sock` - a `net::tcp::TcpSocket` that you wish to stop reading on
  */
 pub fn read_stop(sock: &TcpSocket) ->
     result::Result<(), TcpErrData> {
@@ -387,17 +387,17 @@ pub fn read_stop(sock: &TcpSocket) ->
 }
 
 /**
- * Reads a single chunk of data from `tcp_socket`; block until data/error
+ * Reads a single chunk of data from `TcpSocket`; block until data/error
  * recv'd
  *
  * Does a blocking read operation for a single chunk of data from a
- * `tcp_socket` until a data arrives or an error is received. The provided
+ * `TcpSocket` until a data arrives or an error is received. The provided
  * `timeout_msecs` value is used to raise an error if the timeout period
  * passes without any data received.
  *
  * # Arguments
  *
- * * `sock` - a `net::tcp::tcp_socket` that you wish to read from
+ * * `sock` - a `net::tcp::TcpSocket` that you wish to read from
  * * `timeout_msecs` - a `uint` value, in msecs, to wait before dropping the
  * read attempt. Pass `0u` to wait indefinitely
  */
@@ -408,12 +408,12 @@ pub fn read(sock: &TcpSocket, timeout_msecs: uint)
 }
 
 /**
- * Reads a single chunk of data; returns a `future::future<~[u8]>`
+ * Reads a single chunk of data; returns a `future::Future<~[u8]>`
  * immediately
  *
  * Does a non-blocking read operation for a single chunk of data from a
- * `tcp_socket` and immediately returns a `future` value representing the
- * result. When resolving the returned `future`, it will block until data
+ * `TcpSocket` and immediately returns a `Future` value representing the
+ * result. When resolving the returned `Future`, it will block until data
  * arrives or an error is received. The provided `timeout_msecs`
  * value is used to raise an error if the timeout period passes without any
  * data received.
@@ -421,18 +421,18 @@ pub fn read(sock: &TcpSocket, timeout_msecs: uint)
  * # Safety
  *
  * This function can produce unsafe results if the call to `read_future` is
- * made, the `future::future` value returned is never resolved via
- * `future::get`, and then the `tcp_socket` passed in to `read_future` leaves
+ * made, the `future::Future` value returned is never resolved via
+ * `Future::get`, and then the `TcpSocket` passed in to `read_future` leaves
  * scope and is destructed before the task that runs the libuv read
  * operation completes.
  *
  * As such: If using `read_future`, always be sure to resolve the returned
- * `future` so as to ensure libuv doesn't try to access a released read
+ * `Future` so as to ensure libuv doesn't try to access a released read
  * handle. Otherwise, use the blocking `tcp::read` function instead.
  *
  * # Arguments
  *
- * * `sock` - a `net::tcp::tcp_socket` that you wish to read from
+ * * `sock` - a `net::tcp::TcpSocket` that you wish to read from
  * * `timeout_msecs` - a `uint` value, in msecs, to wait before dropping the
  * read attempt. Pass `0u` to wait indefinitely
  */
@@ -445,7 +445,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
 }
 
 /**
- * Bind an incoming client connection to a `net::tcp::tcp_socket`
+ * Bind an incoming client connection to a `net::tcp::TcpSocket`
  *
  * # Notes
  *
@@ -461,7 +461,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
  *
  * This implies that a port/chan pair must be used to make sure that the
  * `new_connect_cb` call blocks until an attempt to create a
- * `net::tcp::tcp_socket` is completed.
+ * `net::tcp::TcpSocket` is completed.
  *
  * # Example
  *
@@ -469,49 +469,49 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
  * a task spawned by the `new_connect_cb` passed into `listen`
  *
  * ~~~~~~~~~~~
- * net::tcp::listen(remote_ip, remote_port, backlog)
+ * do net::tcp::listen(remote_ip, remote_port, backlog, iotask,
  *     // this callback is ran once after the connection is successfully
  *     // set up
- *     {|kill_ch|
+ *     |kill_ch| {
  *       // pass the kill_ch to your main loop or wherever you want
  *       // to be able to externally kill the server from
- *     }
+ *     })
  *     // this callback is ran when a new connection arrives
- *     {|new_conn, kill_ch|
- *     let cont_po = core::comm::port::<Option<tcp_err_data>>();
- *     let cont_ch = core::comm::chan(cont_po);
- *     task::spawn {||
+ *     |new_conn, kill_ch| {
+ *     let (cont_po, cont_ch) = comm::stream::<option::Option<TcpErrData>>();
+ *     do task::spawn {
  *         let accept_result = net::tcp::accept(new_conn);
- *         if accept_result.is_err() {
- *             core::comm::send(cont_ch, result::get_err(accept_result));
- *             // fail?
- *         }
- *         else {
- *             let sock = result::get(accept_result);
- *             core::comm::send(cont_ch, true);
- *             // do work here
+ *         match accept_result {
+ *             Err(accept_error) => {
+ *                 cont_ch.send(Some(accept_error));
+ *                 // fail?
+ *             },
+ *             Ok(sock) => {
+ *                 cont_ch.send(None);
+ *                 // do work here
+ *             }
  *         }
  *     };
- *     match core::comm::recv(cont_po) {
+ *     match cont_po.recv() {
  *       // shut down listen()
- *       Some(err_data) { core::comm::send(kill_chan, Some(err_data)) }
+ *       Some(err_data) => kill_ch.send(Some(err_data)),
  *       // wait for next connection
- *       None {}
+ *       None => ()
  *     }
  * };
  * ~~~~~~~~~~~
  *
  * # Arguments
  *
- * * `new_conn` - an opaque value used to create a new `tcp_socket`
+ * * `new_conn` - an opaque value used to create a new `TcpSocket`
  *
  * # Returns
  *
- * On success, this function will return a `net::tcp::tcp_socket` as the
- * `ok` variant of a `result`. The `net::tcp::tcp_socket` is anchored within
+ * On success, this function will return a `net::tcp::TcpSocket` as the
+ * `Ok` variant of a `Result`. The `net::tcp::TcpSocket` is anchored within
  * the task that `accept` was called within for its lifetime. On failure,
- * this function will return a `net::tcp::tcp_err_data` record
- * as the `err` variant of a `result`.
+ * this function will return a `net::tcp::TcpErrData` record
+ * as the `Err` variant of a `Result`.
  */
 pub fn accept(new_conn: TcpNewConnection)
     -> result::Result<TcpSocket, TcpErrData> {
@@ -600,27 +600,27 @@ pub fn accept(new_conn: TcpNewConnection)
  *
  * # Arguments
  *
- * * `host_ip` - a `net::ip::ip_addr` representing a unique IP
+ * * `host_ip` - a `net::ip::IpAddr` representing a unique IP
  * (versions 4 or 6)
  * * `port` - a uint representing the port to listen on
  * * `backlog` - a uint representing the number of incoming connections
  * to cache in memory
- * * `hl_loop` - a `uv::hl::high_level_loop` that the tcp request will run on
+ * * `hl_loop` - a `uv_iotask::IoTask` that the tcp request will run on
  * * `on_establish_cb` - a callback that is evaluated if/when the listener
  * is successfully established. it takes no parameters
  * * `new_connect_cb` - a callback to be evaluated, on the libuv thread,
  * whenever a client attempts to conect on the provided ip/port. the
  * callback's arguments are:
  *     * `new_conn` - an opaque type that can be passed to
- *     `net::tcp::accept` in order to be converted to a `tcp_socket`.
- *     * `kill_ch` - channel of type `core::comm::chan<Option<tcp_err_data>>`.
+ *     `net::tcp::accept` in order to be converted to a `TcpSocket`.
+ *     * `kill_ch` - channel of type `core::comm::Chan<Option<tcp_err_data>>`.
  *     this channel can be used to send a message to cause `listen` to begin
  *     closing the underlying libuv data structures.
  *
  * # returns
  *
- * a `result` instance containing empty data of type `()` on a
- * successful/normal shutdown, and a `tcp_listen_err_data` enum in the event
+ * a `Result` instance containing empty data of type `()` on a
+ * successful/normal shutdown, and a `TcpListenErrData` enum in the event
  * of listen exiting because of an error
  */
 pub fn listen(host_ip: ip::IpAddr, port: uint, backlog: uint,
@@ -799,19 +799,19 @@ fn listen_common(host_ip: ip::IpAddr, port: uint, backlog: uint,
 
 
 /**
- * Convert a `net::tcp::tcp_socket` to a `net::tcp::tcp_socket_buf`.
+ * Convert a `net::tcp::TcpSocket` to a `net::tcp::TcpSocketBuf`.
  *
- * This function takes ownership of a `net::tcp::tcp_socket`, returning it
- * stored within a buffered wrapper, which can be converted to a `io::reader`
- * or `io::writer`
+ * This function takes ownership of a `net::tcp::TcpSocket`, returning it
+ * stored within a buffered wrapper, which can be converted to a `io::Reader`
+ * or `io::Writer`
  *
  * # Arguments
  *
- * * `sock` -- a `net::tcp::tcp_socket` that you want to buffer
+ * * `sock` -- a `net::tcp::TcpSocket` that you want to buffer
  *
  * # Returns
  *
- * A buffered wrapper that you can cast as an `io::reader` or `io::writer`
+ * A buffered wrapper that you can cast as an `io::Reader` or `io::Writer`
  */
 pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
     TcpSocketBuf(@TcpBufferedSocketData {
@@ -819,7 +819,7 @@ pub fn socket_buf(sock: TcpSocket) -> TcpSocketBuf {
     })
 }
 
-/// Convenience methods extending `net::tcp::tcp_socket`
+/// Convenience methods extending `net::tcp::TcpSocket`
 pub impl TcpSocket {
     pub fn read_start() -> result::Result<@Port<
         result::Result<~[u8], TcpErrData>>, TcpErrData> {
@@ -862,7 +862,7 @@ pub impl TcpSocket {
     }
 }
 
-/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
+/// Implementation of `io::Reader` trait for a buffered `net::tcp::TcpSocket`
 impl io::Reader for TcpSocketBuf {
     fn read(&self, buf: &mut [u8], len: uint) -> uint {
         if len == 0 { return 0 }
@@ -962,7 +962,7 @@ impl io::Reader for TcpSocketBuf {
     }
 }
 
-/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
+/// Implementation of `io::Reader` trait for a buffered `net::tcp::TcpSocket`
 impl io::Writer for TcpSocketBuf {
     pub fn write(&self, data: &[const u8]) {
         unsafe {
diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs
index 39d3fd569a6..a8a609b1f8a 100644
--- a/src/libstd/sync.rs
+++ b/src/libstd/sync.rs
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -19,7 +19,7 @@ use core::cell::Cell;
 use core::option;
 use core::pipes;
 use core::prelude::*;
-use core::private::{Exclusive, exclusive};
+use core::unstable::{Exclusive, exclusive};
 use core::ptr;
 use core::task;
 use core::util;
@@ -87,7 +87,7 @@ enum Sem<Q> = Exclusive<SemInner<Q>>;
 #[doc(hidden)]
 fn new_sem<Q:Owned>(count: int, q: Q) -> Sem<Q> {
     Sem(exclusive(SemInner {
-        mut count: count, waiters: new_waitqueue(), blocked: q }))
+        count: count, waiters: new_waitqueue(), blocked: q }))
 }
 #[doc(hidden)]
 fn new_sem_and_signal(count: int, num_condvars: uint)
diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs
index 88e4ade4b82..a093351c4a7 100644
--- a/src/libstd/treemap.rs
+++ b/src/libstd/treemap.rs
@@ -10,12 +10,8 @@
 
 //! An ordered map and set implemented as self-balancing binary search
 //! trees. The only requirement for the types is that the key implements
-//! `Ord`, and that the `lt` method provides a total ordering.
+//! `TotalOrd`.
 
-use core::container::{Container, Mutable, Map, Set};
-use core::cmp::{Eq, Ord};
-use core::iter::{BaseIter, ReverseIter};
-use core::option::{Option, Some, None};
 use core::prelude::*;
 
 // This is implemented as an AA tree, which is a simplified variation of
@@ -39,7 +35,7 @@ pub struct TreeMap<K, V> {
     priv length: uint
 }
 
-impl<K:Eq + Ord,V:Eq> Eq for TreeMap<K, V> {
+impl<K: Eq + TotalOrd, V: Eq> Eq for TreeMap<K, V> {
     pure fn eq(&self, other: &TreeMap<K, V>) -> bool {
         if self.len() != other.len() {
             false
@@ -61,7 +57,8 @@ impl<K:Eq + Ord,V:Eq> Eq for TreeMap<K, V> {
 }
 
 // Lexicographical comparison
-pure fn lt<K:Ord,V>(a: &TreeMap<K, V>, b: &TreeMap<K, V>) -> bool {
+pure fn lt<K: Ord + TotalOrd, V>(a: &TreeMap<K, V>,
+                                 b: &TreeMap<K, V>) -> bool {
     let mut x = a.iter();
     let mut y = b.iter();
 
@@ -78,7 +75,7 @@ pure fn lt<K:Ord,V>(a: &TreeMap<K, V>, b: &TreeMap<K, V>) -> bool {
     return a_len < b_len;
 }
 
-impl<K:Ord,V> Ord for TreeMap<K, V> {
+impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> {
     #[inline(always)]
     pure fn lt(&self, other: &TreeMap<K, V>) -> bool {
         lt(self, other)
@@ -97,7 +94,7 @@ impl<K:Ord,V> Ord for TreeMap<K, V> {
     }
 }
 
-impl<K:Ord,V> BaseIter<(&K, &V)> for TreeMap<K, V> {
+impl<K: TotalOrd, V> BaseIter<(&K, &V)> for TreeMap<K, V> {
     /// Visit all key-value pairs in order
     pure fn each(&self, f: fn(&(&self/K, &self/V)) -> bool) {
         each(&self.root, f)
@@ -105,14 +102,14 @@ impl<K:Ord,V> BaseIter<(&K, &V)> for TreeMap<K, V> {
     pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
 }
 
-impl<K:Ord,V> ReverseIter<(&K, &V)> for TreeMap<K, V> {
+impl<K: TotalOrd, V> ReverseIter<(&K, &V)> for TreeMap<K, V> {
     /// Visit all key-value pairs in reverse order
     pure fn each_reverse(&self, f: fn(&(&self/K, &self/V)) -> bool) {
         each_reverse(&self.root, f);
     }
 }
 
-impl<K:Ord,V> Container for TreeMap<K, V> {
+impl<K: TotalOrd, V> Container for TreeMap<K, V> {
     /// Return the number of elements in the map
     pure fn len(&self) -> uint { self.length }
 
@@ -120,7 +117,7 @@ impl<K:Ord,V> Container for TreeMap<K, V> {
     pure fn is_empty(&self) -> bool { self.root.is_none() }
 }
 
-impl<K:Ord,V> Mutable for TreeMap<K, V> {
+impl<K: TotalOrd, V> Mutable for TreeMap<K, V> {
     /// Clear the map, removing all key-value pairs.
     fn clear(&mut self) {
         self.root = None;
@@ -128,7 +125,7 @@ impl<K:Ord,V> Mutable for TreeMap<K, V> {
     }
 }
 
-impl<K:Ord,V> Map<K, V> for TreeMap<K, V> {
+impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
     /// Return true if the map contains a value for the specified key
     pure fn contains_key(&self, key: &K) -> bool {
         self.find(key).is_some()
@@ -146,12 +143,10 @@ impl<K:Ord,V> Map<K, V> for TreeMap<K, V> {
         loop {
             match *current {
               Some(ref r) => {
-                if *key < r.key {
-                    current = &r.left;
-                } else if r.key < *key {
-                    current = &r.right;
-                } else {
-                    return Some(&r.value);
+                match key.cmp(&r.key) {
+                   Less => current = &r.left,
+                   Greater => current = &r.right,
+                   Equal => return Some(&r.value)
                 }
               }
               None => return None
@@ -177,7 +172,7 @@ impl<K:Ord,V> Map<K, V> for TreeMap<K, V> {
     }
 }
 
-pub impl <K:Ord,V> TreeMap<K, V> {
+pub impl<K: TotalOrd, V> TreeMap<K, V> {
     /// Create an empty TreeMap
     static pure fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
 
@@ -207,7 +202,7 @@ pub struct TreeMapIterator<K, V> {
 /// Advance the iterator to the next node (in order) and return a
 /// tuple with a reference to the key and value. If there are no
 /// more nodes, return `None`.
-pub fn map_next<K: Ord, V>(iter: &mut TreeMapIterator/&r<K, V>)
+pub fn map_next<K, V>(iter: &mut TreeMapIterator/&r<K, V>)
                         -> Option<(&r/K, &r/V)> {
     while !iter.stack.is_empty() || iter.node.is_some() {
         match *iter.node {
@@ -226,8 +221,8 @@ pub fn map_next<K: Ord, V>(iter: &mut TreeMapIterator/&r<K, V>)
 }
 
 /// Advance the iterator through the map
-pub fn map_advance<K: Ord, V>(iter: &mut TreeMapIterator/&r<K, V>,
-                          f: fn((&r/K, &r/V)) -> bool) {
+pub fn map_advance<K, V>(iter: &mut TreeMapIterator/&r<K, V>,
+                         f: fn((&r/K, &r/V)) -> bool) {
     loop {
         match map_next(iter) {
           Some(x) => {
@@ -242,25 +237,25 @@ pub struct TreeSet<T> {
     priv map: TreeMap<T, ()>
 }
 
-impl<T:Ord> BaseIter<T> for TreeSet<T> {
+impl<T: TotalOrd> BaseIter<T> for TreeSet<T> {
     /// Visit all values in order
     pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) }
     pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
 }
 
-impl<T:Ord> ReverseIter<T> for TreeSet<T> {
+impl<T: TotalOrd> ReverseIter<T> for TreeSet<T> {
     /// Visit all values in reverse order
     pure fn each_reverse(&self, f: fn(&T) -> bool) {
         self.map.each_key_reverse(f)
     }
 }
 
-impl<T:Eq + Ord> Eq for TreeSet<T> {
+impl<T: Eq + TotalOrd> Eq for TreeSet<T> {
     pure fn eq(&self, other: &TreeSet<T>) -> bool { self.map == other.map }
     pure fn ne(&self, other: &TreeSet<T>) -> bool { self.map != other.map }
 }
 
-impl<T:Ord> Ord for TreeSet<T> {
+impl<T: Ord + TotalOrd> Ord for TreeSet<T> {
     #[inline(always)]
     pure fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map }
     #[inline(always)]
@@ -271,7 +266,7 @@ impl<T:Ord> Ord for TreeSet<T> {
     pure fn gt(&self, other: &TreeSet<T>) -> bool { self.map > other.map }
 }
 
-impl<T:Ord> Container for TreeSet<T> {
+impl<T: TotalOrd> Container for TreeSet<T> {
     /// Return the number of elements in the set
     pure fn len(&self) -> uint { self.map.len() }
 
@@ -279,12 +274,12 @@ impl<T:Ord> Container for TreeSet<T> {
     pure fn is_empty(&self) -> bool { self.map.is_empty() }
 }
 
-impl<T:Ord> Mutable for TreeSet<T> {
+impl<T: TotalOrd> Mutable for TreeSet<T> {
     /// Clear the set, removing all values.
     fn clear(&mut self) { self.map.clear() }
 }
 
-impl<T:Ord> Set<T> for TreeSet<T> {
+impl<T: TotalOrd> Set<T> for TreeSet<T> {
     /// Return true if the set contains a value
     pure fn contains(&self, value: &T) -> bool {
         self.map.contains_key(value)
@@ -309,12 +304,10 @@ impl<T:Ord> Set<T> for TreeSet<T> {
             while a.is_some() && b.is_some() {
                 let a1 = a.unwrap();
                 let b1 = b.unwrap();
-                if a1 < b1 {
-                    a = set_next(&mut x);
-                } else if b1 < a1 {
-                    b = set_next(&mut y);
-                } else {
-                    return false;
+                match a1.cmp(b1) {
+                  Less => a = set_next(&mut x),
+                  Greater => b = set_next(&mut y),
+                  Equal => return false
                 }
             }
         }
@@ -341,13 +334,12 @@ impl<T:Ord> Set<T> for TreeSet<T> {
                 let a1 = a.unwrap();
                 let b1 = b.unwrap();
 
-                if b1 < a1 {
-                    return false
+                match a1.cmp(b1) {
+                  Less => (),
+                  Greater => return false,
+                  Equal => b = set_next(&mut y),
                 }
 
-                if !(a1 < b1) {
-                    b = set_next(&mut y);
-                }
                 a = set_next(&mut x);
             }
         }
@@ -373,11 +365,13 @@ impl<T:Ord> Set<T> for TreeSet<T> {
                 let a1 = a.unwrap();
                 let b1 = b.unwrap();
 
-                if a1 < b1 {
+                let cmp = a1.cmp(b1);
+
+                if cmp == Less {
                     if !f(a1) { return }
                     a = set_next(&mut x);
                 } else {
-                    if !(b1 < a1) { a = set_next(&mut x) }
+                    if cmp == Equal { a = set_next(&mut x) }
                     b = set_next(&mut y);
                 }
             }
@@ -404,11 +398,13 @@ impl<T:Ord> Set<T> for TreeSet<T> {
                 let a1 = a.unwrap();
                 let b1 = b.unwrap();
 
-                if a1 < b1 {
+                let cmp = a1.cmp(b1);
+
+                if cmp == Less {
                     if !f(a1) { return }
                     a = set_next(&mut x);
                 } else {
-                    if b1 < a1 {
+                    if cmp == Greater {
                         if !f(b1) { return }
                     } else {
                         a = set_next(&mut x);
@@ -434,10 +430,13 @@ impl<T:Ord> Set<T> for TreeSet<T> {
             while a.is_some() && b.is_some() {
                 let a1 = a.unwrap();
                 let b1 = b.unwrap();
-                if a1 < b1 {
+
+                let cmp = a1.cmp(b1);
+
+                if cmp == Less {
                     a = set_next(&mut x);
                 } else {
-                    if !(b1 < a1) {
+                    if cmp == Equal {
                         if !f(a1) { return }
                     }
                     b = set_next(&mut y);
@@ -465,12 +464,14 @@ impl<T:Ord> Set<T> for TreeSet<T> {
                 let a1 = a.unwrap();
                 let b1 = b.unwrap();
 
-                if b1 < a1 {
+                let cmp = a1.cmp(b1);
+
+                if cmp == Greater {
                     if !f(b1) { return }
                     b = set_next(&mut y);
                 } else {
                     if !f(a1) { return }
-                    if !(a1 < b1) {
+                    if cmp == Equal {
                         b = set_next(&mut y);
                     }
                     a = set_next(&mut x);
@@ -480,7 +481,7 @@ impl<T:Ord> Set<T> for TreeSet<T> {
     }
 }
 
-pub impl <T:Ord> TreeSet<T> {
+pub impl <T: TotalOrd> TreeSet<T> {
     /// Create an empty TreeSet
     static pure fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }
 
@@ -498,12 +499,12 @@ pub struct TreeSetIterator<T> {
 
 /// Advance the iterator to the next node (in order). If this iterator is
 /// finished, does nothing.
-pub fn set_next<T: Ord>(iter: &mut TreeSetIterator/&r<T>) -> Option<&r/T> {
+pub fn set_next<T>(iter: &mut TreeSetIterator/&r<T>) -> Option<&r/T> {
     do map_next(&mut iter.iter).map |&(value, _)| { value }
 }
 
 /// Advance the iterator through the set
-fn set_advance<T: Ord>(iter: &mut TreeSetIterator/&r<T>,
+fn set_advance<T>(iter: &mut TreeSetIterator/&r<T>,
                        f: fn(&r/T) -> bool) {
     do map_advance(&mut iter.iter) |(k, _)| { f(k) }
 }
@@ -518,14 +519,14 @@ struct TreeNode<K, V> {
     level: uint
 }
 
-pub impl <K:Ord,V> TreeNode<K, V> {
+pub impl<K: TotalOrd, V> TreeNode<K, V> {
     #[inline(always)]
     static pure fn new(key: K, value: V) -> TreeNode<K, V> {
         TreeNode{key: key, value: value, left: None, right: None, level: 1}
     }
 }
 
-pure fn each<K:Ord,V>(node: &r/Option<~TreeNode<K, V>>,
+pure fn each<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>,
                         f: fn(&(&r/K, &r/V)) -> bool) {
     do node.iter |x| {
         each(&x.left, f);
@@ -533,7 +534,7 @@ pure fn each<K:Ord,V>(node: &r/Option<~TreeNode<K, V>>,
     }
 }
 
-pure fn each_reverse<K:Ord,V>(node: &r/Option<~TreeNode<K, V>>,
+pure fn each_reverse<K: TotalOrd, V>(node: &r/Option<~TreeNode<K, V>>,
                                 f: fn(&(&r/K, &r/V)) -> bool) {
     do node.iter |x| {
         each_reverse(&x.right, f);
@@ -542,7 +543,7 @@ pure fn each_reverse<K:Ord,V>(node: &r/Option<~TreeNode<K, V>>,
 }
 
 // Remove left horizontal link by rotating right
-fn skew<K:Ord,V>(node: &mut ~TreeNode<K, V>) {
+fn skew<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
     if node.left.map_default(false, |x| x.level == node.level) {
         let mut save = node.left.swap_unwrap();
         node.left <-> save.right; // save.right now None
@@ -553,7 +554,7 @@ fn skew<K:Ord,V>(node: &mut ~TreeNode<K, V>) {
 
 // Remove dual horizontal link by rotating left and increasing level of
 // the parent
-fn split<K:Ord,V>(node: &mut ~TreeNode<K, V>) {
+fn split<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>) {
     if node.right.map_default(false,
       |x| x.right.map_default(false, |y| y.level == node.level)) {
         let mut save = node.right.swap_unwrap();
@@ -564,24 +565,28 @@ fn split<K:Ord,V>(node: &mut ~TreeNode<K, V>) {
     }
 }
 
-fn insert<K:Ord,V>(node: &mut Option<~TreeNode<K, V>>, key: K,
-                     value: V) -> bool {
+fn insert<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>, key: K,
+                          value: V) -> bool {
     match *node {
       Some(ref mut save) => {
-        if key < save.key {
+        match key.cmp(&save.key) {
+          Less => {
             let inserted = insert(&mut save.left, key, value);
             skew(save);
             split(save);
             inserted
-        } else if save.key < key {
+          }
+          Greater => {
             let inserted = insert(&mut save.right, key, value);
             skew(save);
             split(save);
             inserted
-        } else {
+          }
+          Equal => {
             save.key = key;
             save.value = value;
             false
+          }
         }
       }
       None => {
@@ -591,8 +596,9 @@ fn insert<K:Ord,V>(node: &mut Option<~TreeNode<K, V>>, key: K,
     }
 }
 
-fn remove<K:Ord,V>(node: &mut Option<~TreeNode<K, V>>, key: &K) -> bool {
-    fn heir_swap<K:Ord,V>(node: &mut ~TreeNode<K, V>,
+fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
+                          key: &K) -> bool {
+    fn heir_swap<K: TotalOrd, V>(node: &mut ~TreeNode<K, V>,
                             child: &mut Option<~TreeNode<K, V>>) {
         // *could* be done without recursion, but it won't borrow check
         do child.mutate |mut child| {
@@ -611,11 +617,10 @@ fn remove<K:Ord,V>(node: &mut Option<~TreeNode<K, V>>, key: &K) -> bool {
         return false // bottom of tree
       }
       Some(ref mut save) => {
-        let (removed, this) = if save.key < *key {
-            (remove(&mut save.right, key), false)
-        } else if *key < save.key {
-            (remove(&mut save.left, key), false)
-        } else {
+        let (removed, this) = match key.cmp(&save.key) {
+          Less => (remove(&mut save.left, key), false),
+          Greater => (remove(&mut save.right, key), false),
+          Equal => {
             if save.left.is_some() {
                 if save.right.is_some() {
                     let mut left = save.left.swap_unwrap();
@@ -637,6 +642,7 @@ fn remove<K:Ord,V>(node: &mut Option<~TreeNode<K, V>>, key: &K) -> bool {
             } else {
                 (true, true)
             }
+          }
         };
 
         if !this {
@@ -682,12 +688,9 @@ fn remove<K:Ord,V>(node: &mut Option<~TreeNode<K, V>>, key: &K) -> bool {
 
 #[cfg(test)]
 mod test_treemap {
+    use core::prelude::*;
     use super::*;
-    use core::cmp::{Ord, Eq};
-    use core::option::{Some, Option, None};
     use core::rand;
-    use core::str;
-    use core::vec;
 
     #[test]
     fn find_empty() {
@@ -742,7 +745,8 @@ mod test_treemap {
         assert m.find(&k1) == Some(&v1);
     }
 
-    fn check_equal<K:Eq + Ord,V:Eq>(ctrl: &[(K, V)], map: &TreeMap<K, V>) {
+    fn check_equal<K: Eq + TotalOrd, V: Eq>(ctrl: &[(K, V)],
+                                            map: &TreeMap<K, V>) {
         assert ctrl.is_empty() == map.is_empty();
         for ctrl.each |x| {
             let &(k, v) = x;
@@ -762,11 +766,11 @@ mod test_treemap {
         }
     }
 
-    fn check_left<K:Ord,V>(node: &Option<~TreeNode<K, V>>,
-                             parent: &~TreeNode<K, V>) {
+    fn check_left<K: TotalOrd, V>(node: &Option<~TreeNode<K, V>>,
+                                  parent: &~TreeNode<K, V>) {
         match *node {
           Some(ref r) => {
-            assert r.key < parent.key;
+            assert r.key.cmp(&parent.key) == Less;
             assert r.level == parent.level - 1; // left is black
             check_left(&r.left, r);
             check_right(&r.right, r, false);
@@ -775,11 +779,12 @@ mod test_treemap {
         }
     }
 
-    fn check_right<K:Ord,V>(node: &Option<~TreeNode<K, V>>,
-                              parent: &~TreeNode<K, V>, parent_red: bool) {
+    fn check_right<K: TotalOrd, V>(node: &Option<~TreeNode<K, V>>,
+                                   parent: &~TreeNode<K, V>,
+                                   parent_red: bool) {
         match *node {
           Some(ref r) => {
-            assert r.key > parent.key;
+            assert r.key.cmp(&parent.key) == Greater;
             let red = r.level == parent.level;
             if parent_red { assert !red } // no dual horizontal links
             assert red || r.level == parent.level - 1; // right red or black
@@ -790,7 +795,7 @@ mod test_treemap {
         }
     }
 
-    fn check_structure<K:Ord,V>(map: &TreeMap<K, V>) {
+    fn check_structure<K: TotalOrd, V>(map: &TreeMap<K, V>) {
         match map.root {
           Some(ref r) => {
             check_left(&r.left, r);
diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs
index 37d9b3221b2..52cfc078bac 100644
--- a/src/libstd/uv_global_loop.rs
+++ b/src/libstd/uv_global_loop.rs
@@ -18,9 +18,9 @@ use uv_iotask::{IoTask, spawn_iotask};
 use core::either::{Left, Right};
 use core::libc;
 use core::comm::{Port, Chan, SharedChan, select2i};
-use core::private::global::{global_data_clone_create,
+use core::unstable::global::{global_data_clone_create,
                             global_data_clone};
-use core::private::weak_task::weaken_task;
+use core::unstable::weak_task::weaken_task;
 use core::str;
 use core::task::{task, SingleThreaded, spawn};
 use core::task;