diff options
| author | bors <bors@rust-lang.org> | 2013-02-20 21:22:30 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-02-20 21:22:30 -0800 |
| commit | a02da4ecdef0bc810357db3566f97e9cc1f24c46 (patch) | |
| tree | e61b61fe772d4454a0901fbe48a4828933e5a0eb /src/libstd | |
| parent | 0aa1aaa2c1d095365e341017e443d61a960e0af6 (diff) | |
| parent | bf2a225c0b6f90f61bcaf4a6f33d9eaf424795b6 (diff) | |
| download | rust-a02da4ecdef0bc810357db3566f97e9cc1f24c46.tar.gz rust-a02da4ecdef0bc810357db3566f97e9cc1f24c46.zip | |
auto merge of #5063 : pcwalton/rust/plussing, r=pcwalton
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/arc.rs | 36 | ||||
| -rw-r--r-- | src/libstd/c_vec.rs | 4 | ||||
| -rw-r--r-- | src/libstd/comm.rs | 12 | ||||
| -rw-r--r-- | src/libstd/deque.rs | 2 | ||||
| -rw-r--r-- | src/libstd/flatpipes.rs | 48 | ||||
| -rw-r--r-- | src/libstd/fun_treemap.rs | 4 | ||||
| -rw-r--r-- | src/libstd/json.rs | 16 | ||||
| -rw-r--r-- | src/libstd/list.rs | 18 | ||||
| -rw-r--r-- | src/libstd/oldmap.rs | 28 | ||||
| -rw-r--r-- | src/libstd/oldsmallintmap.rs | 14 | ||||
| -rw-r--r-- | src/libstd/par.rs | 10 | ||||
| -rw-r--r-- | src/libstd/priority_queue.rs | 8 | ||||
| -rw-r--r-- | src/libstd/semver.rs | 2 | ||||
| -rw-r--r-- | src/libstd/serialize.rs | 106 | ||||
| -rw-r--r-- | src/libstd/smallintmap.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sort.rs | 32 | ||||
| -rw-r--r-- | src/libstd/sync.rs | 6 | ||||
| -rw-r--r-- | src/libstd/timer.rs | 4 | ||||
| -rw-r--r-- | src/libstd/treemap.rs | 66 | ||||
| -rw-r--r-- | src/libstd/workcache.rs | 4 |
20 files changed, 212 insertions, 210 deletions
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 66b02ae553c..50f40559807 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -80,7 +80,7 @@ impl &Condvar { struct ARC<T> { x: SharedMutableState<T> } /// Create an atomically reference counted wrapper. -pub fn ARC<T: Const Owned>(data: T) -> ARC<T> { +pub fn ARC<T:Const + Owned>(data: T) -> ARC<T> { ARC { x: unsafe { shared_mutable_state(data) } } } @@ -88,7 +88,7 @@ pub fn ARC<T: Const Owned>(data: T) -> ARC<T> { * Access the underlying data in an atomically reference counted * wrapper. */ -pub fn get<T: Const Owned>(rc: &a/ARC<T>) -> &a/T { +pub fn get<T:Const + Owned>(rc: &a/ARC<T>) -> &a/T { unsafe { get_shared_immutable_state(&rc.x) } } @@ -99,7 +99,7 @@ pub fn get<T: Const Owned>(rc: &a/ARC<T>) -> &a/T { * object. However, one of the `arc` objects can be sent to another task, * allowing them to share the underlying data. */ -pub fn clone<T: Const Owned>(rc: &ARC<T>) -> ARC<T> { +pub fn clone<T:Const + Owned>(rc: &ARC<T>) -> ARC<T> { ARC { x: unsafe { clone_shared_mutable_state(&rc.x) } } } @@ -112,12 +112,12 @@ pub fn clone<T: Const Owned>(rc: &ARC<T>) -> ARC<T> { * unwrap from a task that holds another reference to the same ARC; it is * guaranteed to deadlock. */ -pub fn unwrap<T: Const Owned>(rc: ARC<T>) -> T { +pub fn unwrap<T:Const + Owned>(rc: ARC<T>) -> T { let ARC { x: x } = rc; unsafe { unwrap_shared_mutable_state(x) } } -impl<T: Const Owned> Clone for ARC<T> { +impl<T:Const + Owned> Clone for ARC<T> { fn clone(&self) -> ARC<T> { clone(self) } @@ -133,14 +133,14 @@ struct MutexARCInner<T> { lock: Mutex, failed: bool, data: T } struct MutexARC<T> { x: SharedMutableState<MutexARCInner<T>> } /// Create a mutex-protected ARC with the supplied data. -pub fn MutexARC<T: Owned>(user_data: T) -> MutexARC<T> { +pub fn MutexARC<T:Owned>(user_data: T) -> MutexARC<T> { mutex_arc_with_condvars(user_data, 1) } /** * Create a mutex-protected ARC with the supplied data and a specified number * of condvars (as sync::mutex_with_condvars). */ -pub fn mutex_arc_with_condvars<T: Owned>(user_data: T, +pub fn mutex_arc_with_condvars<T:Owned>(user_data: T, num_condvars: uint) -> MutexARC<T> { let data = MutexARCInner { lock: mutex_with_condvars(num_condvars), @@ -148,7 +148,7 @@ pub fn mutex_arc_with_condvars<T: Owned>(user_data: T, MutexARC { x: unsafe { shared_mutable_state(data) } } } -impl<T: Owned> Clone for MutexARC<T> { +impl<T:Owned> Clone for MutexARC<T> { /// Duplicate a mutex-protected ARC, as arc::clone. fn clone(&self) -> MutexARC<T> { // NB: Cloning the underlying mutex is not necessary. Its reference @@ -157,7 +157,7 @@ impl<T: Owned> Clone for MutexARC<T> { } } -impl<T: Owned> &MutexARC<T> { +impl<T:Owned> &MutexARC<T> { /** * Access the underlying mutable data with mutual exclusion from other @@ -219,7 +219,7 @@ impl<T: Owned> &MutexARC<T> { * Will additionally fail if another task has failed while accessing the arc. */ // FIXME(#3724) make this a by-move method on the arc -pub fn unwrap_mutex_arc<T: Owned>(arc: MutexARC<T>) -> T { +pub fn unwrap_mutex_arc<T:Owned>(arc: MutexARC<T>) -> T { let MutexARC { x: x } = arc; let inner = unsafe { unwrap_shared_mutable_state(x) }; let MutexARCInner { failed: failed, data: data, _ } = inner; @@ -283,14 +283,14 @@ struct RWARC<T> { } /// Create a reader/writer ARC with the supplied data. -pub fn RWARC<T: Const Owned>(user_data: T) -> RWARC<T> { +pub fn RWARC<T:Const + Owned>(user_data: T) -> RWARC<T> { rw_arc_with_condvars(user_data, 1) } /** * Create a reader/writer ARC with the supplied data and a specified number * of condvars (as sync::rwlock_with_condvars). */ -pub fn rw_arc_with_condvars<T: Const Owned>( +pub fn rw_arc_with_condvars<T:Const + Owned>( user_data: T, num_condvars: uint) -> RWARC<T> { @@ -300,7 +300,7 @@ pub fn rw_arc_with_condvars<T: Const Owned>( RWARC { x: unsafe { shared_mutable_state(data) }, cant_nest: () } } -impl<T: Const Owned> RWARC<T> { +impl<T:Const + Owned> RWARC<T> { /// Duplicate a rwlock-protected ARC, as arc::clone. fn clone(&self) -> RWARC<T> { RWARC { x: unsafe { clone_shared_mutable_state(&self.x) }, @@ -309,7 +309,7 @@ impl<T: Const Owned> RWARC<T> { } -impl<T: Const Owned> &RWARC<T> { +impl<T:Const + Owned> &RWARC<T> { /** * Access the underlying data mutably. Locks the rwlock in write mode; * other readers and writers will block. @@ -418,7 +418,7 @@ impl<T: Const Owned> &RWARC<T> { * in write mode. */ // FIXME(#3724) make this a by-move method on the arc -pub fn unwrap_rw_arc<T: Const Owned>(arc: RWARC<T>) -> T { +pub fn unwrap_rw_arc<T:Const + Owned>(arc: RWARC<T>) -> T { let RWARC { x: x, _ } = arc; let inner = unsafe { unwrap_shared_mutable_state(x) }; let RWARCInner { failed: failed, data: data, _ } = inner; @@ -432,7 +432,7 @@ pub fn unwrap_rw_arc<T: Const Owned>(arc: RWARC<T>) -> T { // lock it. This wraps the unsafety, with the justification that the 'lock' // field is never overwritten; only 'failed' and 'data'. #[doc(hidden)] -fn borrow_rwlock<T: Const Owned>(state: *const RWARCInner<T>) -> *RWlock { +fn borrow_rwlock<T:Const + Owned>(state: *const RWARCInner<T>) -> *RWlock { unsafe { cast::transmute(&const (*state).lock) } } @@ -444,7 +444,7 @@ pub enum RWWriteMode<T> = /// The "read permission" token used for RWARC.write_downgrade(). pub enum RWReadMode<T> = (&T, sync::RWlockReadMode); -impl<T: Const Owned> &RWWriteMode<T> { +impl<T:Const + Owned> &RWWriteMode<T> { /// Access the pre-downgrade RWARC in write mode. fn write<U>(blk: fn(x: &mut T) -> U) -> U { match *self { @@ -474,7 +474,7 @@ impl<T: Const Owned> &RWWriteMode<T> { } } -impl<T: Const Owned> &RWReadMode<T> { +impl<T:Const + Owned> &RWReadMode<T> { /// Access the post-downgrade rwlock in read mode. fn read<U>(blk: fn(x: &T) -> U) -> U { match *self { diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 696b2753ea4..5af596c1f84 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -120,7 +120,7 @@ pub unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@()) * * Fails if `ofs` is greater or equal to the length of the vector */ -pub fn get<T: Copy>(t: CVec<T>, ofs: uint) -> T { +pub fn get<T:Copy>(t: CVec<T>, ofs: uint) -> T { assert ofs < len(t); return unsafe { *ptr::mut_offset(t.base, ofs) }; } @@ -130,7 +130,7 @@ pub fn get<T: Copy>(t: CVec<T>, ofs: uint) -> T { * * Fails if `ofs` is greater or equal to the length of the vector */ -pub fn set<T: Copy>(t: CVec<T>, ofs: uint, v: T) { +pub fn set<T:Copy>(t: CVec<T>, ofs: uint, v: T) { assert ofs < len(t); unsafe { *ptr::mut_offset(t.base, ofs) = v }; } diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index c2c21002b19..9478a392796 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -25,19 +25,19 @@ pub struct DuplexStream<T, U> { priv port: Port<U>, } -impl<T: Owned, U: Owned> GenericChan<T> for DuplexStream<T, U> { +impl<T:Owned,U:Owned> GenericChan<T> for DuplexStream<T, U> { fn send(x: T) { self.chan.send(x) } } -impl<T: Owned, U: Owned> GenericSmartChan<T> for DuplexStream<T, U> { +impl<T:Owned,U:Owned> GenericSmartChan<T> for DuplexStream<T, U> { fn try_send(x: T) -> bool { self.chan.try_send(x) } } -impl<T: Owned, U: Owned> GenericPort<U> for DuplexStream<T, U> { +impl<T:Owned,U:Owned> GenericPort<U> for DuplexStream<T, U> { fn recv() -> U { self.port.recv() } @@ -47,20 +47,20 @@ impl<T: Owned, U: Owned> GenericPort<U> for DuplexStream<T, U> { } } -impl<T: Owned, U: Owned> Peekable<U> for DuplexStream<T, U> { +impl<T:Owned,U:Owned> Peekable<U> for DuplexStream<T, U> { pure fn peek() -> bool { self.port.peek() } } -impl<T: Owned, U: Owned> Selectable for DuplexStream<T, U> { +impl<T:Owned,U:Owned> Selectable for DuplexStream<T, U> { pure fn header() -> *pipes::PacketHeader { self.port.header() } } /// Creates a bidirectional stream. -pub fn DuplexStream<T: Owned, U: Owned>() +pub fn DuplexStream<T:Owned,U:Owned>() -> (DuplexStream<T, U>, DuplexStream<U, T>) { let (p1, c2) = pipes::stream(); diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index b1285dac9f4..0ac76cefd6b 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -198,7 +198,7 @@ mod tests { assert *deq.get(3) == d; } - fn test_parameterized<T: Copy Eq Durable>(a: T, b: T, c: T, d: T) { + fn test_parameterized<T:Copy + Eq + Durable>(a: T, b: T, c: T, d: T) { let mut deq = Deque::new(); assert deq.len() == 0; deq.add_front(a); diff --git a/src/libstd/flatpipes.rs b/src/libstd/flatpipes.rs index cff30587607..f97e5ee6800 100644 --- a/src/libstd/flatpipes.rs +++ b/src/libstd/flatpipes.rs @@ -129,7 +129,7 @@ pub mod serial { } /// Create a `FlatPort` from a `Port<~[u8]>` - pub fn pipe_port<T: Decodable<DefaultDecoder>>( + pub fn pipe_port<T:Decodable<DefaultDecoder>>( port: Port<~[u8]> ) -> PipePort<T> { let unflat: DeserializingUnflattener<DefaultDecoder, T> = @@ -140,7 +140,7 @@ pub mod serial { } /// Create a `FlatChan` from a `Chan<~[u8]>` - pub fn pipe_chan<T: Encodable<DefaultEncoder>>( + pub fn pipe_chan<T:Encodable<DefaultEncoder>>( chan: Chan<~[u8]> ) -> PipeChan<T> { let flat: SerializingFlattener<DefaultEncoder, T> = @@ -189,7 +189,7 @@ pub mod pod { pub type PipeChan<T> = FlatChan<T, PodFlattener<T>, PipeByteChan>; /// Create a `FlatPort` from a `Reader` - pub fn reader_port<T: Copy Owned, R: Reader>( + pub fn reader_port<T:Copy + Owned,R:Reader>( reader: R ) -> ReaderPort<T, R> { let unflat: PodUnflattener<T> = PodUnflattener::new(); @@ -198,7 +198,7 @@ pub mod pod { } /// Create a `FlatChan` from a `Writer` - pub fn writer_chan<T: Copy Owned, W: Writer>( + pub fn writer_chan<T:Copy + Owned,W:Writer>( writer: W ) -> WriterChan<T, W> { let flat: PodFlattener<T> = PodFlattener::new(); @@ -207,21 +207,21 @@ pub mod pod { } /// Create a `FlatPort` from a `Port<~[u8]>` - pub fn pipe_port<T: Copy Owned>(port: Port<~[u8]>) -> PipePort<T> { + pub fn pipe_port<T:Copy + Owned>(port: Port<~[u8]>) -> PipePort<T> { let unflat: PodUnflattener<T> = PodUnflattener::new(); let byte_port = PipeBytePort::new(port); FlatPort::new(unflat, byte_port) } /// Create a `FlatChan` from a `Chan<~[u8]>` - pub fn pipe_chan<T: Copy Owned>(chan: Chan<~[u8]>) -> PipeChan<T> { + pub fn pipe_chan<T:Copy + Owned>(chan: Chan<~[u8]>) -> PipeChan<T> { let flat: PodFlattener<T> = PodFlattener::new(); let byte_chan = PipeByteChan::new(chan); FlatChan::new(flat, byte_chan) } /// Create a pair of `FlatChan` and `FlatPort`, backed by pipes - pub fn pipe_stream<T: Copy Owned>() -> (PipePort<T>, PipeChan<T>) { + pub fn pipe_stream<T:Copy + Owned>() -> (PipePort<T>, PipeChan<T>) { let (port, chan) = pipes::stream(); return (pipe_port(port), pipe_chan(chan)); } @@ -358,7 +358,7 @@ pub mod flatteners { bogus: () } - pub impl<T: Copy Owned> Unflattener<T> for PodUnflattener<T> { + pub impl<T:Copy + Owned> Unflattener<T> for PodUnflattener<T> { fn unflatten(&self, buf: ~[u8]) -> T { assert size_of::<T>() != 0; assert size_of::<T>() == buf.len(); @@ -368,7 +368,7 @@ pub mod flatteners { } } - pub impl<T: Copy Owned> Flattener<T> for PodFlattener<T> { + pub impl<T:Copy + Owned> Flattener<T> for PodFlattener<T> { fn flatten(&self, val: T) -> ~[u8] { assert size_of::<T>() != 0; let val: *T = ptr::to_unsafe_ptr(&val); @@ -377,7 +377,7 @@ pub mod flatteners { } } - pub impl<T: Copy Owned> PodUnflattener<T> { + pub impl<T:Copy + Owned> PodUnflattener<T> { static fn new() -> PodUnflattener<T> { PodUnflattener { bogus: () @@ -385,7 +385,7 @@ pub mod flatteners { } } - pub impl<T: Copy Owned> PodFlattener<T> { + pub impl<T:Copy + Owned> PodFlattener<T> { static fn new() -> PodFlattener<T> { PodFlattener { bogus: () @@ -406,21 +406,21 @@ pub mod flatteners { serialize_value: SerializeValue<T> } - pub impl<D: Decoder, T: Decodable<D>> Unflattener<T> + pub impl<D:Decoder,T:Decodable<D>> Unflattener<T> for DeserializingUnflattener<D, T> { fn unflatten(&self, buf: ~[u8]) -> T { (self.deserialize_buffer)(buf) } } - pub impl<S: Encoder, T: Encodable<S>> Flattener<T> + pub impl<S:Encoder,T:Encodable<S>> Flattener<T> for SerializingFlattener<S, T> { fn flatten(&self, val: T) -> ~[u8] { (self.serialize_value)(&val) } } - pub impl<D: Decoder, T: Decodable<D>> DeserializingUnflattener<D, T> { + pub impl<D:Decoder,T:Decodable<D>> DeserializingUnflattener<D, T> { static fn new(deserialize_buffer: DeserializeBuffer<T>) -> DeserializingUnflattener<D, T> { DeserializingUnflattener { @@ -429,7 +429,7 @@ pub mod flatteners { } } - pub impl<S: Encoder, T: Encodable<S>> SerializingFlattener<S, T> { + pub impl<S:Encoder,T:Encodable<S>> SerializingFlattener<S, T> { static fn new(serialize_value: SerializeValue<T>) -> SerializingFlattener<S, T> { SerializingFlattener { @@ -519,7 +519,7 @@ pub mod bytepipes { writer: W } - pub impl<R: Reader> BytePort for ReaderBytePort<R> { + pub impl<R:Reader> BytePort for ReaderBytePort<R> { fn try_recv(&self, count: uint) -> Option<~[u8]> { let mut left = count; let mut bytes = ~[]; @@ -541,13 +541,13 @@ pub mod bytepipes { } } - pub impl<W: Writer> ByteChan for WriterByteChan<W> { + pub impl<W:Writer> ByteChan for WriterByteChan<W> { fn send(&self, val: ~[u8]) { self.writer.write(val); } } - pub impl<R: Reader> ReaderBytePort<R> { + pub impl<R:Reader> ReaderBytePort<R> { static fn new(r: R) -> ReaderBytePort<R> { ReaderBytePort { reader: r @@ -555,7 +555,7 @@ pub mod bytepipes { } } - pub impl<W: Writer> WriterByteChan<W> { + pub impl<W:Writer> WriterByteChan<W> { static fn new(w: W) -> WriterByteChan<W> { WriterByteChan { writer: w @@ -765,7 +765,7 @@ mod test { type WriterChanFactory<F> = ~fn(TcpSocketBuf) -> FlatChan<int, F, WriterByteChan<TcpSocketBuf>>; - fn test_some_tcp_stream<U: Unflattener<int>, F: Flattener<int>>( + fn test_some_tcp_stream<U:Unflattener<int>,F:Flattener<int>>( reader_port: ReaderPortFactory<U>, writer_chan: WriterChanFactory<F>, port: uint) { @@ -901,7 +901,7 @@ mod test { pod::pipe_port(port) } - fn test_try_recv_none1<P: BytePort>(loader: PortLoader<P>) { + fn test_try_recv_none1<P:BytePort>(loader: PortLoader<P>) { let bytes = ~[]; let port = loader(bytes); let res: Option<int> = port.try_recv(); @@ -917,7 +917,7 @@ mod test { test_try_recv_none1(pipe_port_loader); } - fn test_try_recv_none2<P: BytePort>(loader: PortLoader<P>) { + fn test_try_recv_none2<P:BytePort>(loader: PortLoader<P>) { // The control word in the protocol is interrupted let bytes = ~[0]; let port = loader(bytes); @@ -934,7 +934,7 @@ mod test { test_try_recv_none2(pipe_port_loader); } - fn test_try_recv_none3<P: BytePort>(loader: PortLoader<P>) { + fn test_try_recv_none3<P:BytePort>(loader: PortLoader<P>) { const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; // The control word is followed by garbage let bytes = CONTINUE.to_vec() + ~[0]; @@ -952,7 +952,7 @@ mod test { test_try_recv_none3(pipe_port_loader); } - fn test_try_recv_none4<P: BytePort>(+loader: PortLoader<P>) { + fn test_try_recv_none4<P:BytePort>(+loader: PortLoader<P>) { assert do task::try || { const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD]; // The control word is followed by a valid length, diff --git a/src/libstd/fun_treemap.rs b/src/libstd/fun_treemap.rs index 8af2f350e51..0729987958a 100644 --- a/src/libstd/fun_treemap.rs +++ b/src/libstd/fun_treemap.rs @@ -34,7 +34,7 @@ enum TreeNode<K, V> { pub fn init<K, V>() -> Treemap<K, V> { @Empty } /// Insert a value into the map -pub fn insert<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, k: K, v: V) +pub fn insert<K:Copy + Eq + Ord,V:Copy>(m: Treemap<K, V>, k: K, v: V) -> Treemap<K, V> { @match m { @Empty => Node(@k, @v, @Empty, @Empty), @@ -49,7 +49,7 @@ pub fn insert<K: Copy Eq Ord, V: Copy>(m: Treemap<K, V>, k: K, v: V) } /// Find a value based on the key -pub fn find<K: Eq Ord, V: Copy>(m: Treemap<K, V>, k: K) -> Option<V> { +pub fn find<K:Eq + Ord,V:Copy>(m: Treemap<K, V>, k: K) -> Option<V> { match *m { Empty => None, Node(@ref kk, @copy v, left, right) => { diff --git a/src/libstd/json.rs b/src/libstd/json.rs index e8278bb1b35..8d0daa323ad 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -323,7 +323,7 @@ pub impl serialize::Encoder for PrettyEncoder { } } -pub impl<S: serialize::Encoder> serialize::Encodable<S> for Json { +pub impl<S:serialize::Encoder> serialize::Encodable<S> for Json { fn encode(&self, s: &S) { match *self { Number(v) => v.encode(s), @@ -1150,7 +1150,7 @@ impl ToJson for @~str { fn to_json() -> Json { String(copy *self) } } -impl<A: ToJson, B: ToJson> ToJson for (A, B) { +impl<A:ToJson,B:ToJson> ToJson for (A, B) { fn to_json() -> Json { match self { (ref a, ref b) => { @@ -1160,7 +1160,7 @@ impl<A: ToJson, B: ToJson> ToJson for (A, B) { } } -impl<A: ToJson, B: ToJson, C: ToJson> ToJson for (A, B, C) { +impl<A:ToJson,B:ToJson,C:ToJson> ToJson for (A, B, C) { fn to_json() -> Json { match self { (ref a, ref b, ref c) => { @@ -1170,11 +1170,11 @@ impl<A: ToJson, B: ToJson, C: ToJson> ToJson for (A, B, C) { } } -impl<A: ToJson> ToJson for ~[A] { +impl<A:ToJson> ToJson for ~[A] { fn to_json() -> Json { List(self.map(|elt| elt.to_json())) } } -impl<A: ToJson Copy> ToJson for LinearMap<~str, A> { +impl<A:ToJson + Copy> ToJson for LinearMap<~str, A> { fn to_json() -> Json { let mut d = LinearMap::new(); for self.each |&(key, value)| { @@ -1184,7 +1184,7 @@ impl<A: ToJson Copy> ToJson for LinearMap<~str, A> { } } -impl<A: ToJson> ToJson for Option<A> { +impl<A:ToJson> ToJson for Option<A> { fn to_json() -> Json { match self { None => Null, @@ -1282,13 +1282,13 @@ mod tests { // two fns copied from libsyntax/util/testing.rs. // Should they be in their own crate? - pub pure fn check_equal_ptr<T : cmp::Eq> (given : &T, expected: &T) { + pub pure fn check_equal_ptr<T:cmp::Eq> (given : &T, expected: &T) { if !((given == expected) && (expected == given )) { fail!(fmt!("given %?, expected %?",given,expected)); } } - pub pure fn check_equal<T : cmp::Eq> (given : T, expected: T) { + pub pure fn check_equal<T:cmp::Eq> (given : T, expected: T) { if !((given == expected) && (expected == given )) { fail!(fmt!("given %?, expected %?",given,expected)); } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 5feac4ad454..f6cbd9a099b 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -23,7 +23,7 @@ pub enum List<T> { } /// Create a list from a vector -pub pure fn from_vec<T: Copy>(v: &[T]) -> @List<T> { +pub pure fn from_vec<T:Copy>(v: &[T]) -> @List<T> { vec::foldr(v, @Nil::<T>, |h, t| @Cons(*h, t)) } @@ -40,7 +40,7 @@ pub pure fn from_vec<T: Copy>(v: &[T]) -> @List<T> { * * z - The initial value * * f - The function to apply */ -pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T { +pub fn foldl<T:Copy,U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T { let mut accum: T = z; do iter(ls) |elt| { accum = f(&accum, elt);} accum @@ -53,7 +53,7 @@ pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -pub pure fn find<T: Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> { +pub pure fn find<T:Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> { let mut ls = ls; loop { ls = match *ls { @@ -67,7 +67,7 @@ pub pure fn find<T: Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> { } /// Returns true if a list contains an element with the given value -pub fn has<T: Copy Eq>(ls: @List<T>, elt: T) -> bool { +pub fn has<T:Copy + Eq>(ls: @List<T>, elt: T) -> bool { for each(ls) |e| { if *e == elt { return true; } } @@ -75,7 +75,7 @@ pub fn has<T: Copy Eq>(ls: @List<T>, elt: T) -> bool { } /// Returns true if the list is empty -pub pure fn is_empty<T: Copy>(ls: @List<T>) -> bool { +pub pure fn is_empty<T:Copy>(ls: @List<T>) -> bool { match *ls { Nil => true, _ => false @@ -90,7 +90,7 @@ pub pure fn len<T>(ls: @List<T>) -> uint { } /// Returns all but the first element of a list -pub pure fn tail<T: Copy>(ls: @List<T>) -> @List<T> { +pub pure fn tail<T:Copy>(ls: @List<T>) -> @List<T> { match *ls { Cons(_, tl) => return tl, Nil => fail!(~"list empty") @@ -98,7 +98,7 @@ pub pure fn tail<T: Copy>(ls: @List<T>) -> @List<T> { } /// Returns the first element of a list -pub pure fn head<T: Copy>(ls: @List<T>) -> T { +pub pure fn head<T:Copy>(ls: @List<T>) -> T { match *ls { Cons(copy hd, _) => hd, // makes me sad @@ -107,7 +107,7 @@ pub pure fn head<T: Copy>(ls: @List<T>) -> T { } /// Appends one list to another -pub pure fn append<T: Copy>(l: @List<T>, m: @List<T>) -> @List<T> { +pub pure fn append<T:Copy>(l: @List<T>, m: @List<T>) -> @List<T> { match *l { Nil => return m, Cons(copy x, xs) => { @@ -120,7 +120,7 @@ pub pure fn append<T: Copy>(l: @List<T>, m: @List<T>) -> @List<T> { /* /// Push one element into the front of a list, returning a new list /// THIS VERSION DOESN'T ACTUALLY WORK -pure fn push<T: Copy>(ll: &mut @list<T>, vv: T) { +pure fn push<T:Copy>(ll: &mut @list<T>, vv: T) { ll = &mut @cons(vv, *ll) } */ diff --git a/src/libstd/oldmap.rs b/src/libstd/oldmap.rs index 701268e044a..53692cd3be5 100644 --- a/src/libstd/oldmap.rs +++ b/src/libstd/oldmap.rs @@ -76,7 +76,7 @@ pub mod chained { FoundAfter(@Entry<K,V>, @Entry<K,V>) } - priv impl<K:Eq IterBytes Hash, V> T<K, V> { + priv impl<K:Eq + IterBytes + Hash,V> T<K, V> { pure fn search_rem(k: &K, h: uint, idx: uint, e_root: @Entry<K,V>) -> SearchResult<K,V> { let mut e0 = e_root; @@ -156,19 +156,19 @@ pub mod chained { } } - impl<K: Eq IterBytes Hash, V> Container for T<K, V> { + impl<K:Eq + IterBytes + Hash,V> Container for T<K, V> { pure fn len(&self) -> uint { self.count } pure fn is_empty(&self) -> bool { self.count == 0 } } - impl<K: Eq IterBytes Hash, V> Mutable for T<K, V> { + impl<K:Eq + IterBytes + Hash,V> Mutable for T<K, V> { fn clear(&mut self) { self.count = 0u; self.chains = chains(initial_capacity); } } - impl<K: Eq IterBytes Hash, V> T<K, V> { + impl<K:Eq + IterBytes + Hash,V> T<K, V> { pure fn contains_key(&self, k: &K) -> bool { let hash = k.hash_keyed(0,0) as uint; match self.search_tbl(k, hash) { @@ -252,7 +252,7 @@ pub mod chained { } } - impl<K: Eq IterBytes Hash Copy, V: Copy> T<K, V> { + impl<K:Eq + IterBytes + Hash + Copy,V:Copy> T<K, V> { pure fn find(&self, k: &K) -> Option<V> { match self.search_tbl(k, k.hash_keyed(0,0) as uint) { NotFound => None, @@ -325,7 +325,7 @@ pub mod chained { } } - impl<K:Eq IterBytes Hash Copy ToStr, V: ToStr Copy> T<K, V> { + impl<K:Eq + IterBytes + Hash + Copy + ToStr,V:ToStr + Copy> T<K, V> { fn to_writer(wr: io::Writer) { if self.count == 0u { wr.write_str(~"{}"); @@ -347,7 +347,8 @@ pub mod chained { } } - impl<K:Eq IterBytes Hash Copy ToStr, V: ToStr Copy> ToStr for T<K, V> { + impl<K:Eq + IterBytes + Hash + Copy + ToStr,V:ToStr + Copy> ToStr + for T<K, V> { pure fn to_str(&self) -> ~str { unsafe { // Meh -- this should be safe @@ -356,7 +357,7 @@ pub mod chained { } } - impl<K:Eq IterBytes Hash Copy, V: Copy> ops::Index<K, V> for T<K, V> { + impl<K:Eq + IterBytes + Hash + Copy,V:Copy> ops::Index<K, V> for T<K, V> { pure fn index(&self, k: K) -> V { self.get(&k) } @@ -366,7 +367,7 @@ pub mod chained { vec::from_elem(nchains, None) } - pub fn mk<K:Eq IterBytes Hash, V: Copy>() -> T<K,V> { + pub fn mk<K:Eq + IterBytes + Hash,V:Copy>() -> T<K,V> { let slf: T<K, V> = @HashMap_ {count: 0u, chains: chains(initial_capacity)}; slf @@ -378,18 +379,19 @@ Function: hashmap Construct a hashmap. */ -pub fn HashMap<K:Eq IterBytes Hash Const, V: Copy>() +pub fn HashMap<K:Eq + IterBytes + Hash + Const,V:Copy>() -> HashMap<K, V> { chained::mk() } /// Convenience function for adding keys to a hashmap with nil type keys -pub fn set_add<K:Eq IterBytes Hash Const Copy>(set: Set<K>, key: K) -> bool { +pub fn set_add<K:Eq + IterBytes + Hash + Const + Copy>(set: Set<K>, key: K) + -> bool { set.insert(key, ()) } /// Convert a set into a vector. -pub pure fn vec_from_set<T:Eq IterBytes Hash Copy>(s: Set<T>) -> ~[T] { +pub pure fn vec_from_set<T:Eq + IterBytes + Hash + Copy>(s: Set<T>) -> ~[T] { do vec::build_sized(s.len()) |push| { for s.each_key() |&k| { push(k); @@ -398,7 +400,7 @@ pub pure fn vec_from_set<T:Eq IterBytes Hash Copy>(s: Set<T>) -> ~[T] { } /// Construct a hashmap from a vector -pub fn hash_from_vec<K: Eq IterBytes Hash Const Copy, V: Copy>( +pub fn hash_from_vec<K:Eq + IterBytes + Hash + Const + Copy,V:Copy>( items: &[(K, V)]) -> HashMap<K, V> { let map = HashMap(); for vec::each(items) |item| { diff --git a/src/libstd/oldsmallintmap.rs b/src/libstd/oldsmallintmap.rs index c4ba465acea..a31309d7980 100644 --- a/src/libstd/oldsmallintmap.rs +++ b/src/libstd/oldsmallintmap.rs @@ -32,7 +32,7 @@ pub enum SmallIntMap<T> { } /// Create a smallintmap -pub fn mk<T: Copy>() -> SmallIntMap<T> { +pub fn mk<T:Copy>() -> SmallIntMap<T> { let v = DVec(); SmallIntMap_(@SmallIntMap_ { v: v } ) } @@ -42,7 +42,7 @@ pub fn mk<T: Copy>() -> SmallIntMap<T> { * the specified key then the original value is replaced. */ #[inline(always)] -pub fn insert<T: Copy>(self: SmallIntMap<T>, key: uint, val: T) { +pub fn insert<T:Copy>(self: SmallIntMap<T>, key: uint, val: T) { //io::println(fmt!("%?", key)); self.v.grow_set_elt(key, &None, Some(val)); } @@ -51,7 +51,7 @@ pub fn insert<T: Copy>(self: SmallIntMap<T>, key: uint, val: T) { * Get the value for the specified key. If the key does not exist * in the map then returns none */ -pub pure fn find<T: Copy>(self: SmallIntMap<T>, key: uint) -> Option<T> { +pub pure fn find<T:Copy>(self: SmallIntMap<T>, key: uint) -> Option<T> { if key < self.v.len() { return self.v.get_elt(key); } return None::<T>; } @@ -63,7 +63,7 @@ pub pure fn find<T: Copy>(self: SmallIntMap<T>, key: uint) -> Option<T> { * * If the key does not exist in the map */ -pub pure fn get<T: Copy>(self: SmallIntMap<T>, key: uint) -> T { +pub pure fn get<T:Copy>(self: SmallIntMap<T>, key: uint) -> T { match find(self, key) { None => { error!("smallintmap::get(): key not present"); @@ -74,7 +74,7 @@ pub pure fn get<T: Copy>(self: SmallIntMap<T>, key: uint) -> T { } /// Returns true if the map contains a value for the specified key -pub pure fn contains_key<T: Copy>(self: SmallIntMap<T>, key: uint) -> bool { +pub pure fn contains_key<T:Copy>(self: SmallIntMap<T>, key: uint) -> bool { return !find(self, key).is_none(); } @@ -100,7 +100,7 @@ impl<V> Mutable for SmallIntMap<V> { } /// Implements the map::map interface for smallintmap -impl<V: Copy> SmallIntMap<V> { +impl<V:Copy> SmallIntMap<V> { #[inline(always)] fn insert(key: uint, value: V) -> bool { let exists = contains_key(self, key); @@ -162,7 +162,7 @@ impl<V: Copy> SmallIntMap<V> { } } -impl<V: Copy> ops::Index<uint, V> for SmallIntMap<V> { +impl<V:Copy> ops::Index<uint, V> for SmallIntMap<V> { pure fn index(&self, key: uint) -> V { unsafe { get(*self, key) diff --git a/src/libstd/par.rs b/src/libstd/par.rs index c48f56dd143..0839ce18123 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -34,7 +34,7 @@ const min_granularity : uint = 1024u; * This is used to build most of the other parallel vector functions, * like map or alli. */ -fn map_slices<A: Copy Owned, B: Copy Owned>( +fn map_slices<A:Copy + Owned,B:Copy + Owned>( xs: &[A], f: &fn() -> ~fn(uint, v: &[A]) -> B) -> ~[B] { @@ -90,7 +90,7 @@ fn map_slices<A: Copy Owned, B: Copy Owned>( } /// A parallel version of map. -pub fn map<A: Copy Owned, B: Copy Owned>( +pub fn map<A:Copy + Owned,B:Copy + Owned>( xs: &[A], fn_factory: &fn() -> ~fn(&A) -> B) -> ~[B] { vec::concat(map_slices(xs, || { let f = fn_factory(); @@ -101,7 +101,7 @@ pub fn map<A: Copy Owned, B: Copy Owned>( } /// A parallel version of mapi. -pub fn mapi<A: Copy Owned, B: Copy Owned>( +pub fn mapi<A:Copy + Owned,B:Copy + Owned>( xs: &[A], fn_factory: &fn() -> ~fn(uint, &A) -> B) -> ~[B] { @@ -120,7 +120,7 @@ pub fn mapi<A: Copy Owned, B: Copy Owned>( } /// Returns true if the function holds for all elements in the vector. -pub fn alli<A: Copy Owned>( +pub fn alli<A:Copy + Owned>( xs: &[A], fn_factory: &fn() -> ~fn(uint, &A) -> bool) -> bool { @@ -135,7 +135,7 @@ pub fn alli<A: Copy Owned>( } /// Returns true if the function holds for any elements in the vector. -pub fn any<A: Copy Owned>( +pub fn any<A:Copy + Owned>( xs: &[A], fn_factory: &fn() -> ~fn(&A) -> bool) -> bool { do vec::any(map_slices(xs, || { diff --git a/src/libstd/priority_queue.rs b/src/libstd/priority_queue.rs index b216834a205..f642bf52f65 100644 --- a/src/libstd/priority_queue.rs +++ b/src/libstd/priority_queue.rs @@ -27,7 +27,7 @@ pub struct PriorityQueue<T> { priv data: ~[T], } -impl<T: Ord> BaseIter<T> for PriorityQueue<T> { +impl<T:Ord> BaseIter<T> for PriorityQueue<T> { /// Visit all values in the underlying vector. /// /// The values are **not** visited in order. @@ -35,7 +35,7 @@ impl<T: Ord> BaseIter<T> for PriorityQueue<T> { pure fn size_hint(&self) -> Option<uint> { self.data.size_hint() } } -impl<T: Ord> Container for PriorityQueue<T> { +impl<T:Ord> Container for PriorityQueue<T> { /// Returns the length of the queue pure fn len(&self) -> uint { self.data.len() } @@ -43,12 +43,12 @@ impl<T: Ord> Container for PriorityQueue<T> { pure fn is_empty(&self) -> bool { self.data.is_empty() } } -impl<T: Ord> Mutable for PriorityQueue<T> { +impl<T:Ord> Mutable for PriorityQueue<T> { /// Drop all items from the queue fn clear(&mut self) { self.data.truncate(0) } } -impl <T: Ord> PriorityQueue<T> { +impl <T:Ord> PriorityQueue<T> { /// Returns the greatest item in the queue - fails if empty pure fn top(&self) -> &self/T { &self.data[0] } diff --git a/src/libstd/semver.rs b/src/libstd/semver.rs index 97c60330a7e..5f96687127c 100644 --- a/src/libstd/semver.rs +++ b/src/libstd/semver.rs @@ -392,4 +392,4 @@ fn test_spec_order() { assert a < b; i += 1; } -} \ No newline at end of file +} diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 9b7cf8adce5..3178e141097 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -105,218 +105,218 @@ pub trait Decoder { fn read_tup_elt<T>(&self, idx: uint, f: fn() -> T) -> T; } -pub trait Encodable<S: Encoder> { +pub trait Encodable<S:Encoder> { fn encode(&self, s: &S); } -pub trait Decodable<D: Decoder> { +pub trait Decodable<D:Decoder> { static fn decode(&self, d: &D) -> Self; } -pub impl<S: Encoder> Encodable<S> for uint { +pub impl<S:Encoder> Encodable<S> for uint { fn encode(&self, s: &S) { s.emit_uint(*self) } } -pub impl<D: Decoder> Decodable<D> for uint { +pub impl<D:Decoder> Decodable<D> for uint { static fn decode(&self, d: &D) -> uint { d.read_uint() } } -pub impl<S: Encoder> Encodable<S> for u8 { +pub impl<S:Encoder> Encodable<S> for u8 { fn encode(&self, s: &S) { s.emit_u8(*self) } } -pub impl<D: Decoder> Decodable<D> for u8 { +pub impl<D:Decoder> Decodable<D> for u8 { static fn decode(&self, d: &D) -> u8 { d.read_u8() } } -pub impl<S: Encoder> Encodable<S> for u16 { +pub impl<S:Encoder> Encodable<S> for u16 { fn encode(&self, s: &S) { s.emit_u16(*self) } } -pub impl<D: Decoder> Decodable<D> for u16 { +pub impl<D:Decoder> Decodable<D> for u16 { static fn decode(&self, d: &D) -> u16 { d.read_u16() } } -pub impl<S: Encoder> Encodable<S> for u32 { +pub impl<S:Encoder> Encodable<S> for u32 { fn encode(&self, s: &S) { s.emit_u32(*self) } } -pub impl<D: Decoder> Decodable<D> for u32 { +pub impl<D:Decoder> Decodable<D> for u32 { static fn decode(&self, d: &D) -> u32 { d.read_u32() } } -pub impl<S: Encoder> Encodable<S> for u64 { +pub impl<S:Encoder> Encodable<S> for u64 { fn encode(&self, s: &S) { s.emit_u64(*self) } } -pub impl<D: Decoder> Decodable<D> for u64 { +pub impl<D:Decoder> Decodable<D> for u64 { static fn decode(&self, d: &D) -> u64 { d.read_u64() } } -pub impl<S: Encoder> Encodable<S> for int { +pub impl<S:Encoder> Encodable<S> for int { fn encode(&self, s: &S) { s.emit_int(*self) } } -pub impl<D: Decoder> Decodable<D> for int { +pub impl<D:Decoder> Decodable<D> for int { static fn decode(&self, d: &D) -> int { d.read_int() } } -pub impl<S: Encoder> Encodable<S> for i8 { +pub impl<S:Encoder> Encodable<S> for i8 { fn encode(&self, s: &S) { s.emit_i8(*self) } } -pub impl<D: Decoder> Decodable<D> for i8 { +pub impl<D:Decoder> Decodable<D> for i8 { static fn decode(&self, d: &D) -> i8 { d.read_i8() } } -pub impl<S: Encoder> Encodable<S> for i16 { +pub impl<S:Encoder> Encodable<S> for i16 { fn encode(&self, s: &S) { s.emit_i16(*self) } } -pub impl<D: Decoder> Decodable<D> for i16 { +pub impl<D:Decoder> Decodable<D> for i16 { static fn decode(&self, d: &D) -> i16 { d.read_i16() } } -pub impl<S: Encoder> Encodable<S> for i32 { +pub impl<S:Encoder> Encodable<S> for i32 { fn encode(&self, s: &S) { s.emit_i32(*self) } } -pub impl<D: Decoder> Decodable<D> for i32 { +pub impl<D:Decoder> Decodable<D> for i32 { static fn decode(&self, d: &D) -> i32 { d.read_i32() } } -pub impl<S: Encoder> Encodable<S> for i64 { +pub impl<S:Encoder> Encodable<S> for i64 { fn encode(&self, s: &S) { s.emit_i64(*self) } } -pub impl<D: Decoder> Decodable<D> for i64 { +pub impl<D:Decoder> Decodable<D> for i64 { static fn decode(&self, d: &D) -> i64 { d.read_i64() } } -pub impl<S: Encoder> Encodable<S> for &str { +pub impl<S:Encoder> Encodable<S> for &str { fn encode(&self, s: &S) { s.emit_borrowed_str(*self) } } -pub impl<S: Encoder> Encodable<S> for ~str { +pub impl<S:Encoder> Encodable<S> for ~str { fn encode(&self, s: &S) { s.emit_owned_str(*self) } } -pub impl<D: Decoder> Decodable<D> for ~str { +pub impl<D:Decoder> Decodable<D> for ~str { static fn decode(&self, d: &D) -> ~str { d.read_owned_str() } } -pub impl<S: Encoder> Encodable<S> for @str { +pub impl<S:Encoder> Encodable<S> for @str { fn encode(&self, s: &S) { s.emit_managed_str(*self) } } -pub impl<D: Decoder> Decodable<D> for @str { +pub impl<D:Decoder> Decodable<D> for @str { static fn decode(&self, d: &D) -> @str { d.read_managed_str() } } -pub impl<S: Encoder> Encodable<S> for float { +pub impl<S:Encoder> Encodable<S> for float { fn encode(&self, s: &S) { s.emit_float(*self) } } -pub impl<D: Decoder> Decodable<D> for float { +pub impl<D:Decoder> Decodable<D> for float { static fn decode(&self, d: &D) -> float { d.read_float() } } -pub impl<S: Encoder> Encodable<S> for f32 { +pub impl<S:Encoder> Encodable<S> for f32 { fn encode(&self, s: &S) { s.emit_f32(*self) } } -pub impl<D: Decoder> Decodable<D> for f32 { +pub impl<D:Decoder> Decodable<D> for f32 { static fn decode(&self, d: &D) -> f32 { d.read_f32() } } -pub impl<S: Encoder> Encodable<S> for f64 { +pub impl<S:Encoder> Encodable<S> for f64 { fn encode(&self, s: &S) { s.emit_f64(*self) } } -pub impl<D: Decoder> Decodable<D> for f64 { +pub impl<D:Decoder> Decodable<D> for f64 { static fn decode(&self, d: &D) -> f64 { d.read_f64() } } -pub impl<S: Encoder> Encodable<S> for bool { +pub impl<S:Encoder> Encodable<S> for bool { fn encode(&self, s: &S) { s.emit_bool(*self) } } -pub impl<D: Decoder> Decodable<D> for bool { +pub impl<D:Decoder> Decodable<D> for bool { static fn decode(&self, d: &D) -> bool { d.read_bool() } } -pub impl<S: Encoder> Encodable<S> for () { +pub impl<S:Encoder> Encodable<S> for () { fn encode(&self, s: &S) { s.emit_nil() } } -pub impl<D: Decoder> Decodable<D> for () { +pub impl<D:Decoder> Decodable<D> for () { static fn decode(&self, d: &D) -> () { d.read_nil() } } -pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for &T { +pub impl<S:Encoder,T:Encodable<S>> Encodable<S> for &T { fn encode(&self, s: &S) { s.emit_borrowed(|| (**self).encode(s)) } } -pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for ~T { +pub impl<S:Encoder,T:Encodable<S>> Encodable<S> for ~T { fn encode(&self, s: &S) { s.emit_owned(|| (**self).encode(s)) } } -pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for ~T { +pub impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~T { static fn decode(&self, d: &D) -> ~T { d.read_owned(|| ~Decodable::decode(d)) } } -pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for @T { +pub impl<S:Encoder,T:Encodable<S>> Encodable<S> for @T { fn encode(&self, s: &S) { s.emit_managed(|| (**self).encode(s)) } } -pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for @T { +pub impl<D:Decoder,T:Decodable<D>> Decodable<D> for @T { static fn decode(&self, d: &D) -> @T { d.read_managed(|| @Decodable::decode(d)) } } -pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for &[T] { +pub impl<S:Encoder,T:Encodable<S>> Encodable<S> for &[T] { fn encode(&self, s: &S) { do s.emit_borrowed_vec(self.len()) { for self.eachi |i, e| { @@ -326,7 +326,7 @@ pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for &[T] { } } -pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for ~[T] { +pub impl<S:Encoder,T:Encodable<S>> Encodable<S> for ~[T] { fn encode(&self, s: &S) { do s.emit_owned_vec(self.len()) { for self.eachi |i, e| { @@ -336,7 +336,7 @@ pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for ~[T] { } } -pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for ~[T] { +pub impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~[T] { static fn decode(&self, d: &D) -> ~[T] { do d.read_owned_vec |len| { do vec::from_fn(len) |i| { @@ -346,7 +346,7 @@ pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for ~[T] { } } -pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for @[T] { +pub impl<S:Encoder,T:Encodable<S>> Encodable<S> for @[T] { fn encode(&self, s: &S) { do s.emit_managed_vec(self.len()) { for self.eachi |i, e| { @@ -356,7 +356,7 @@ pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for @[T] { } } -pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for @[T] { +pub impl<D:Decoder,T:Decodable<D>> Decodable<D> for @[T] { static fn decode(&self, d: &D) -> @[T] { do d.read_managed_vec |len| { do at_vec::from_fn(len) |i| { @@ -366,7 +366,7 @@ pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for @[T] { } } -pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for Option<T> { +pub impl<S:Encoder,T:Encodable<S>> Encodable<S> for Option<T> { fn encode(&self, s: &S) { do s.emit_enum(~"option") { match *self { @@ -381,7 +381,7 @@ pub impl<S: Encoder, T: Encodable<S>> Encodable<S> for Option<T> { } } -pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for Option<T> { +pub impl<D:Decoder,T:Decodable<D>> Decodable<D> for Option<T> { static fn decode(&self, d: &D) -> Option<T> { do d.read_enum(~"option") { do d.read_enum_variant |i| { @@ -396,7 +396,7 @@ pub impl<D: Decoder, T: Decodable<D>> Decodable<D> for Option<T> { } } -pub impl<S: Encoder, T0: Encodable<S>, T1: Encodable<S>> Encodable<S> +pub impl<S:Encoder,T0:Encodable<S>,T1:Encodable<S>> Encodable<S> for (T0, T1) { fn encode(&self, s: &S) { match *self { @@ -410,7 +410,7 @@ pub impl<S: Encoder, T0: Encodable<S>, T1: Encodable<S>> Encodable<S> } } -pub impl<D: Decoder, T0: Decodable<D>, T1: Decodable<D>> Decodable<D> +pub impl<D:Decoder,T0:Decodable<D>,T1:Decodable<D>> Decodable<D> for (T0, T1) { static fn decode(&self, d: &D) -> (T0, T1) { do d.read_tup(2) { @@ -552,7 +552,7 @@ pub trait EncoderHelpers { fn emit_from_vec<T>(&self, v: &[T], f: fn(v: &T)); } -pub impl<S: Encoder> EncoderHelpers for S { +pub impl<S:Encoder> EncoderHelpers for S { fn emit_from_vec<T>(&self, v: &[T], f: fn(v: &T)) { do self.emit_owned_vec(v.len()) { for v.eachi |i, e| { @@ -568,7 +568,7 @@ pub trait DecoderHelpers { fn read_to_vec<T>(&self, f: fn() -> T) -> ~[T]; } -pub impl<D: Decoder> DecoderHelpers for D { +pub impl<D:Decoder> DecoderHelpers for D { fn read_to_vec<T>(&self, f: fn() -> T) -> ~[T] { do self.read_owned_vec |len| { do vec::from_fn(len) |i| { diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 382cd658663..68d22f7c919 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -131,7 +131,7 @@ pub impl<V> SmallIntMap<V> { } } -pub impl<V: Copy> SmallIntMap<V> { +pub impl<V:Copy> SmallIntMap<V> { fn update_with_key(&mut self, key: uint, val: V, ff: fn(uint, V, V) -> V) -> bool { let new_val = match self.find(&key) { diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 3450205aa95..d2515df3e1b 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -25,12 +25,12 @@ type Le<T> = pure fn(v1: &T, v2: &T) -> bool; * Has worst case O(n log n) performance, best case O(n), but * is not space efficient. This is a stable sort. */ -pub pure fn merge_sort<T: Copy>(v: &[const T], le: Le<T>) -> ~[T] { +pub pure fn merge_sort<T:Copy>(v: &[const T], le: Le<T>) -> ~[T] { type Slice = (uint, uint); unsafe {return merge_sort_(v, (0u, len(v)), le);} - fn merge_sort_<T: Copy>(v: &[const T], slice: Slice, le: Le<T>) + fn merge_sort_<T:Copy>(v: &[const T], slice: Slice, le: Le<T>) -> ~[T] { let begin = slice.first(); let end = slice.second(); @@ -45,7 +45,7 @@ pub pure fn merge_sort<T: Copy>(v: &[const T], le: Le<T>) -> ~[T] { return merge(le, merge_sort_(v, a, le), merge_sort_(v, b, le)); } - fn merge<T: Copy>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] { + fn merge<T:Copy>(le: Le<T>, a: &[T], b: &[T]) -> ~[T] { let mut rs = vec::with_capacity(len(a) + len(b)); let a_len = len(a); let mut a_ix = 0; @@ -103,7 +103,7 @@ pub fn quick_sort<T>(arr: &mut [T], compare_func: Le<T>) { qsort::<T>(arr, 0u, len::<T>(arr) - 1u, compare_func); } -fn qsort3<T: Copy Ord Eq>(arr: &mut [T], left: int, right: int) { +fn qsort3<T:Copy + Ord + Eq>(arr: &mut [T], left: int, right: int) { if right <= left { return; } let v: T = arr[right]; let mut i: int = left - 1; @@ -160,7 +160,7 @@ fn qsort3<T: Copy Ord Eq>(arr: &mut [T], left: int, right: int) { * * This is an unstable sort. */ -pub fn quick_sort3<T: Copy Ord Eq>(arr: &mut [T]) { +pub fn quick_sort3<T:Copy + Ord + Eq>(arr: &mut [T]) { if arr.len() <= 1 { return; } qsort3(arr, 0, (arr.len() - 1) as int); } @@ -169,7 +169,7 @@ pub trait Sort { fn qsort(self); } -impl<T: Copy Ord Eq> Sort for &mut [T] { +impl<T:Copy + Ord + Eq> Sort for &mut [T] { fn qsort(self) { quick_sort3(self); } } @@ -177,7 +177,7 @@ const MIN_MERGE: uint = 64; const MIN_GALLOP: uint = 7; const INITIAL_TMP_STORAGE: uint = 128; -pub fn tim_sort<T: Copy Ord>(array: &mut [T]) { +pub fn tim_sort<T:Copy + Ord>(array: &mut [T]) { let size = array.len(); if size < 2 { return; @@ -216,7 +216,7 @@ pub fn tim_sort<T: Copy Ord>(array: &mut [T]) { ms.merge_force_collapse(array); } -fn binarysort<T: Copy Ord>(array: &mut [T], start: uint) { +fn binarysort<T:Copy + Ord>(array: &mut [T], start: uint) { let size = array.len(); let mut start = start; assert start <= size; @@ -266,7 +266,7 @@ pure fn min_run_length(n: uint) -> uint { return n + r; } -fn count_run_ascending<T: Copy Ord>(array: &mut [T]) -> uint { +fn count_run_ascending<T:Copy + Ord>(array: &mut [T]) -> uint { let size = array.len(); assert size > 0; if size == 1 { return 1; } @@ -286,7 +286,7 @@ fn count_run_ascending<T: Copy Ord>(array: &mut [T]) -> uint { return run; } -pure fn gallop_left<T: Copy Ord>(key: &const T, array: &[const T], +pure fn gallop_left<T:Copy + Ord>(key: &const T, array: &[const T], hint: uint) -> uint { let size = array.len(); assert size != 0 && hint < size; @@ -335,7 +335,7 @@ pure fn gallop_left<T: Copy Ord>(key: &const T, array: &[const T], return ofs; } -pure fn gallop_right<T: Copy Ord>(key: &const T, array: &[const T], +pure fn gallop_right<T:Copy + Ord>(key: &const T, array: &[const T], hint: uint) -> uint { let size = array.len(); assert size != 0 && hint < size; @@ -404,7 +404,7 @@ fn MergeState<T>() -> MergeState<T> { } } -impl<T: Copy Ord> MergeState<T> { +impl<T:Copy + Ord> MergeState<T> { fn push_run(&self, run_base: uint, run_len: uint) { let tmp = RunState{base: run_base, len: run_len}; self.runs.push(tmp); @@ -708,7 +708,7 @@ impl<T: Copy Ord> MergeState<T> { } #[inline(always)] -fn copy_vec<T: Copy>(dest: &mut [T], s1: uint, +fn copy_vec<T:Copy>(dest: &mut [T], s1: uint, from: &[const T], s2: uint, len: uint) { assert s1+len <= dest.len() && s2+len <= from.len(); @@ -1019,7 +1019,7 @@ mod big_tests { tabulate_managed(low, high); } - fn multiplyVec<T: Copy>(arr: &[const T], num: uint) -> ~[T] { + fn multiplyVec<T:Copy>(arr: &[const T], num: uint) -> ~[T] { let size = arr.len(); let res = do vec::from_fn(num) |i| { arr[i % size] @@ -1035,7 +1035,7 @@ mod big_tests { } fn tabulate_unique(lo: uint, hi: uint) { - fn isSorted<T: Ord>(arr: &[const T]) { + fn isSorted<T:Ord>(arr: &[const T]) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { fail!(~"Array not sorted"); @@ -1107,7 +1107,7 @@ mod big_tests { } fn tabulate_managed(lo: uint, hi: uint) { - fn isSorted<T: Ord>(arr: &[const @T]) { + fn isSorted<T:Ord>(arr: &[const @T]) { for uint::range(0, arr.len()-1) |i| { if arr[i] > arr[i+1] { fail!(~"Array not sorted"); diff --git a/src/libstd/sync.rs b/src/libstd/sync.rs index fd0b0d6be3a..66d17392417 100644 --- a/src/libstd/sync.rs +++ b/src/libstd/sync.rs @@ -84,7 +84,7 @@ struct SemInner<Q> { enum Sem<Q> = Exclusive<SemInner<Q>>; #[doc(hidden)] -fn new_sem<Q: Owned>(count: int, q: Q) -> Sem<Q> { +fn new_sem<Q:Owned>(count: int, q: Q) -> Sem<Q> { Sem(exclusive(SemInner { mut count: count, waiters: new_waitqueue(), blocked: q })) } @@ -99,7 +99,7 @@ fn new_sem_and_signal(count: int, num_condvars: uint) } #[doc(hidden)] -impl<Q: Owned> &Sem<Q> { +impl<Q:Owned> &Sem<Q> { fn acquire() { let mut waiter_nobe = None; unsafe { @@ -167,7 +167,7 @@ type SemRelease = SemReleaseGeneric<()>; type SemAndSignalRelease = SemReleaseGeneric<~[Waitqueue]>; struct SemReleaseGeneric<Q> { sem: &Sem<Q> } -impl<Q: Owned> Drop for SemReleaseGeneric<Q> { +impl<Q:Owned> Drop for SemReleaseGeneric<Q> { fn finalize(&self) { self.sem.release(); } diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 6e1e6a331a2..6768ff23248 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -39,7 +39,7 @@ use core; * * ch - a channel of type T to send a `val` on * * val - a value of type T to send over the provided `ch` */ -pub fn delayed_send<T: Owned>(iotask: &IoTask, +pub fn delayed_send<T:Owned>(iotask: &IoTask, msecs: uint, ch: &Chan<T>, val: T) { @@ -123,7 +123,7 @@ pub fn sleep(iotask: &IoTask, msecs: uint) { * on the provided port in the allotted timeout period, then the result will * be a `Some(T)`. If not, then `None` will be returned. */ -pub fn recv_timeout<T: Copy Owned>(iotask: &IoTask, +pub fn recv_timeout<T:Copy + Owned>(iotask: &IoTask, msecs: uint, wait_po: &Port<T>) -> Option<T> { diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index e4279a57ad5..eb3093a2745 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -39,7 +39,7 @@ pub struct TreeMap<K, V> { priv length: uint } -impl<K: Eq Ord, V: Eq> Eq for TreeMap<K, V> { +impl<K:Eq + Ord,V:Eq> Eq for TreeMap<K, V> { pure fn eq(&self, other: &TreeMap<K, V>) -> bool { if self.len() != other.len() { false @@ -66,7 +66,7 @@ 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,V>(a: &TreeMap<K, V>, b: &TreeMap<K, V>) -> bool { let mut x = a.iter(); let mut y = b.iter(); @@ -85,7 +85,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,V> Ord for TreeMap<K, V> { #[inline(always)] pure fn lt(&self, other: &TreeMap<K, V>) -> bool { lt(self, other) @@ -104,7 +104,7 @@ impl<K: Ord, V> Ord for TreeMap<K, V> { } } -impl<K: Ord, V> BaseIter<(&K, &V)> for TreeMap<K, V> { +impl<K:Ord,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) @@ -112,14 +112,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:Ord,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:Ord,V> Container for TreeMap<K, V> { /// Return the number of elements in the map pure fn len(&self) -> uint { self.length } @@ -127,7 +127,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:Ord,V> Mutable for TreeMap<K, V> { /// Clear the map, removing all key-value pairs. fn clear(&mut self) { self.root = None; @@ -135,7 +135,7 @@ impl<K: Ord, V> Mutable for TreeMap<K, V> { } } -impl<K: Ord, V> Map<K, V> for TreeMap<K, V> { +impl<K:Ord,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() @@ -184,7 +184,7 @@ impl<K: Ord, V> Map<K, V> for TreeMap<K, V> { } } -impl <K: Ord, V> TreeMap<K, V> { +impl <K:Ord,V> TreeMap<K, V> { /// Create an empty TreeMap static pure fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} } @@ -212,7 +212,7 @@ pub struct TreeMapIterator<K, V> { priv current: Option<&~TreeNode<K, V>> } -impl <K: Ord, V> TreeMapIterator<K, V> { +impl <K:Ord,V> TreeMapIterator<K, V> { // Returns the current node, or None if this iterator is at the end. fn get(&const self) -> Option<(&self/K, &self/V)> { match self.current { @@ -224,7 +224,7 @@ impl <K: Ord, V> TreeMapIterator<K, V> { /// Advance the iterator to the next node (in order). If this iterator /// is finished, does nothing. -pub fn map_next<K: Ord, V>(iter: &mut TreeMapIterator/&a<K, V>) { +pub fn map_next<K:Ord,V>(iter: &mut TreeMapIterator/&a<K, V>) { while !iter.stack.is_empty() || iter.node.is_some() { match *iter.node { Some(ref x) => { @@ -246,25 +246,25 @@ pub struct TreeSet<T> { priv map: TreeMap<T, ()> } -impl<T: Ord> BaseIter<T> for TreeSet<T> { +impl<T:Ord> 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:Ord> 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 + Ord> 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> Ord for TreeSet<T> { #[inline(always)] pure fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map } #[inline(always)] @@ -275,7 +275,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:Ord> Container for TreeSet<T> { /// Return the number of elements in the set pure fn len(&self) -> uint { self.map.len() } @@ -283,12 +283,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:Ord> 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:Ord> 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) @@ -510,7 +510,7 @@ impl<T: Ord> Set<T> for TreeSet<T> { } } -impl <T: Ord> TreeSet<T> { +impl <T:Ord> TreeSet<T> { /// Create an empty TreeSet static pure fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} } @@ -526,7 +526,7 @@ pub struct TreeSetIterator<T> { priv iter: TreeMapIterator<T, ()> } -impl <T: Ord> TreeSetIterator<T> { +impl <T:Ord> TreeSetIterator<T> { /// Returns the current node, or None if this iterator is at the end. fn get(&const self) -> Option<&self/T> { match self.iter.get() { @@ -538,7 +538,7 @@ impl <T: Ord> 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/&a<T>) { +pub fn set_next<T:Ord>(iter: &mut TreeSetIterator/&a<T>) { map_next(&mut iter.iter); } @@ -552,14 +552,14 @@ struct TreeNode<K, V> { level: uint } -impl <K: Ord, V> TreeNode<K, V> { +impl <K:Ord,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:Ord,V>(node: &r/Option<~TreeNode<K, V>>, f: fn(&(&r/K, &r/V)) -> bool) { do node.iter |x| { each(&x.left, f); @@ -567,7 +567,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:Ord,V>(node: &r/Option<~TreeNode<K, V>>, f: fn(&(&r/K, &r/V)) -> bool) { do node.iter |x| { each_reverse(&x.right, f); @@ -576,7 +576,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:Ord,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 @@ -587,7 +587,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:Ord,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(); @@ -598,7 +598,7 @@ fn split<K: Ord, V>(node: &mut ~TreeNode<K, V>) { } } -fn insert<K: Ord, V>(node: &mut Option<~TreeNode<K, V>>, key: K, +fn insert<K:Ord,V>(node: &mut Option<~TreeNode<K, V>>, key: K, value: V) -> bool { match *node { Some(ref mut save) => { @@ -625,8 +625,8 @@ 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:Ord,V>(node: &mut Option<~TreeNode<K, V>>, key: &K) -> bool { + fn heir_swap<K:Ord,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| { @@ -772,7 +772,7 @@ 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 + Ord,V:Eq>(ctrl: &[(K, V)], map: &TreeMap<K, V>) { assert ctrl.is_empty() == map.is_empty(); for ctrl.each |x| { let &(k, v) = x; @@ -792,7 +792,7 @@ mod test_treemap { } } - fn check_left<K: Ord, V>(node: &Option<~TreeNode<K, V>>, + fn check_left<K:Ord,V>(node: &Option<~TreeNode<K, V>>, parent: &~TreeNode<K, V>) { match *node { Some(ref r) => { @@ -805,7 +805,7 @@ mod test_treemap { } } - fn check_right<K: Ord, V>(node: &Option<~TreeNode<K, V>>, + fn check_right<K:Ord,V>(node: &Option<~TreeNode<K, V>>, parent: &~TreeNode<K, V>, parent_red: bool) { match *node { Some(ref r) => { @@ -820,7 +820,7 @@ mod test_treemap { } } - fn check_structure<K: Ord, V>(map: &TreeMap<K, V>) { + fn check_structure<K:Ord,V>(map: &TreeMap<K, V>) { match map.root { Some(ref r) => { check_left(&r.left, r); diff --git a/src/libstd/workcache.rs b/src/libstd/workcache.rs index 70c03c69d2d..4de7c1b9925 100644 --- a/src/libstd/workcache.rs +++ b/src/libstd/workcache.rs @@ -138,7 +138,7 @@ impl WorkKey { type WorkMap = LinearMap<WorkKey, ~str>; -pub impl<S: Encoder> Encodable<S> for WorkMap { +pub impl<S:Encoder> Encodable<S> for WorkMap { fn encode(&self, s: &S) { let mut d = ~[]; for self.each |&(k, v)| { @@ -149,7 +149,7 @@ pub impl<S: Encoder> Encodable<S> for WorkMap { } } -pub impl<D: Decoder> Decodable<D> for WorkMap { +pub impl<D:Decoder> Decodable<D> for WorkMap { static fn decode(&self, d: &D) -> WorkMap { let v : ~[(WorkKey,~str)] = Decodable::decode(d); let mut w = LinearMap::new(); |
