diff options
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/at_vec.rs | 6 | ||||
| -rw-r--r-- | src/libcore/cmp.rs | 16 | ||||
| -rw-r--r-- | src/libcore/dlist.rs | 4 | ||||
| -rw-r--r-- | src/libcore/dvec.rs | 2 | ||||
| -rw-r--r-- | src/libcore/either.rs | 2 | ||||
| -rw-r--r-- | src/libcore/hash.rs | 4 | ||||
| -rw-r--r-- | src/libcore/hashmap.rs | 30 | ||||
| -rw-r--r-- | src/libcore/io.rs | 12 | ||||
| -rw-r--r-- | src/libcore/iter-trait.rs | 6 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 14 | ||||
| -rw-r--r-- | src/libcore/num/num.rs | 2 | ||||
| -rw-r--r-- | src/libcore/option.rs | 10 | ||||
| -rw-r--r-- | src/libcore/pipes.rs | 80 | ||||
| -rw-r--r-- | src/libcore/private.rs | 20 | ||||
| -rw-r--r-- | src/libcore/private/global.rs | 12 | ||||
| -rw-r--r-- | src/libcore/rand.rs | 6 | ||||
| -rw-r--r-- | src/libcore/reflect.rs | 6 | ||||
| -rw-r--r-- | src/libcore/result.rs | 8 | ||||
| -rw-r--r-- | src/libcore/task/local_data.rs | 8 | ||||
| -rw-r--r-- | src/libcore/task/local_data_priv.rs | 16 | ||||
| -rw-r--r-- | src/libcore/task/mod.rs | 4 | ||||
| -rw-r--r-- | src/libcore/to_bytes.rs | 22 | ||||
| -rw-r--r-- | src/libcore/to_str.rs | 10 | ||||
| -rw-r--r-- | src/libcore/tuple.rs | 14 | ||||
| -rw-r--r-- | src/libcore/util.rs | 2 | ||||
| -rw-r--r-- | src/libcore/vec.rs | 138 |
26 files changed, 227 insertions, 227 deletions
diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 565fe11d3f4..1880feaf496 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -101,7 +101,7 @@ pub pure fn build_sized_opt<A>(size: Option<uint>, // Appending #[inline(always)] -pub pure fn append<T: Copy>(lhs: @[T], rhs: &[const T]) -> @[T] { +pub pure fn append<T:Copy>(lhs: @[T], rhs: &[const T]) -> @[T] { do build_sized(lhs.len() + rhs.len()) |push| { for vec::each(lhs) |x| { push(*x); } for uint::range(0, rhs.len()) |i| { push(rhs[i]); } @@ -137,7 +137,7 @@ pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> @[T] { +pub pure fn from_elem<T:Copy>(n_elts: uint, t: T) -> @[T] { do build_sized(n_elts) |push| { let mut i: uint = 0u; while i < n_elts { push(copy t); i += 1u; } @@ -173,7 +173,7 @@ pub mod traits { use kinds::Copy; use ops::Add; - pub impl<T: Copy> Add<&[const T],@[T]> for @[T] { + pub impl<T:Copy> Add<&[const T],@[T]> for @[T] { #[inline(always)] pure fn add(&self, rhs: & &self/[const T]) -> @[T] { append(*self, (*rhs)) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 7cd4d4c9bc3..fd99235bd27 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -56,41 +56,41 @@ pub trait Ord { } #[inline(always)] -pub pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool { +pub pure fn lt<T:Ord>(v1: &T, v2: &T) -> bool { (*v1).lt(v2) } #[inline(always)] -pub pure fn le<T: Ord>(v1: &T, v2: &T) -> bool { +pub pure fn le<T:Ord>(v1: &T, v2: &T) -> bool { (*v1).le(v2) } #[inline(always)] -pub pure fn eq<T: Eq>(v1: &T, v2: &T) -> bool { +pub pure fn eq<T:Eq>(v1: &T, v2: &T) -> bool { (*v1).eq(v2) } #[inline(always)] -pub pure fn ne<T: Eq>(v1: &T, v2: &T) -> bool { +pub pure fn ne<T:Eq>(v1: &T, v2: &T) -> bool { (*v1).ne(v2) } #[inline(always)] -pub pure fn ge<T: Ord>(v1: &T, v2: &T) -> bool { +pub pure fn ge<T:Ord>(v1: &T, v2: &T) -> bool { (*v1).ge(v2) } #[inline(always)] -pub pure fn gt<T: Ord>(v1: &T, v2: &T) -> bool { +pub pure fn gt<T:Ord>(v1: &T, v2: &T) -> bool { (*v1).gt(v2) } #[inline(always)] -pub pure fn min<T: Ord>(v1: T, v2: T) -> T { +pub pure fn min<T:Ord>(v1: T, v2: T) -> T { if v1 < v2 { v1 } else { v2 } } #[inline(always)] -pub pure fn max<T: Ord>(v1: T, v2: T) -> T { +pub pure fn max<T:Ord>(v1: T, v2: T) -> T { if v1 > v2 { v1 } else { v2 } } diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 09de94f1aaf..35807364889 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -106,7 +106,7 @@ pub pure fn from_elem<T>(data: T) -> @mut DList<T> { list } -pub fn from_vec<T: Copy>(vec: &[T]) -> @mut DList<T> { +pub fn from_vec<T:Copy>(vec: &[T]) -> @mut DList<T> { do vec::foldl(DList(), vec) |list,data| { list.push(*data); // Iterating left-to-right -- add newly to the tail. list @@ -457,7 +457,7 @@ impl<T> DList<T> { } } -impl<T: Copy> DList<T> { +impl<T:Copy> DList<T> { /// Remove data from the head of the list. O(1). fn pop(@mut self) -> Option<T> { self.pop_n().map(|nobe| nobe.data) diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 03a921d7ea5..7651b737bf3 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -227,7 +227,7 @@ impl<A> DVec<A> { } } -impl<A: Copy> DVec<A> { +impl<A:Copy> DVec<A> { /** * Append all elements of a vector to the end of the list * diff --git a/src/libcore/either.rs b/src/libcore/either.rs index 72aecdd8295..93b28233acd 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -41,7 +41,7 @@ pub fn either<T, U, V>(f_left: fn(&T) -> V, } } -pub fn lefts<T: Copy, U>(eithers: &[Either<T, U>]) -> ~[T] { +pub fn lefts<T:Copy,U>(eithers: &[Either<T, U>]) -> ~[T] { //! Extracts from a vector of either all the left values do vec::build_sized(eithers.len()) |push| { diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index 40a9de0cea3..7c1448c88ee 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -59,7 +59,7 @@ pub trait HashUtil { pure fn hash() -> u64; } -impl<A: Hash> HashUtil for A { +impl<A:Hash> HashUtil for A { #[inline(always)] pure fn hash() -> u64 { self.hash_keyed(0,0) } } @@ -74,7 +74,7 @@ pub trait Streaming { fn reset(); } -impl<A: IterBytes> Hash for A { +impl<A:IterBytes> Hash for A { #[inline(always)] pure fn hash_keyed(k0: u64, k1: u64) -> u64 { unsafe { diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 9cc7c2b760c..07c7780898f 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -56,14 +56,14 @@ pub mod linear { ((capacity as float) * 3. / 4.) as uint } - pub fn linear_map_with_capacity<K: Eq Hash, V>( + pub fn linear_map_with_capacity<K:Eq + Hash,V>( initial_capacity: uint) -> LinearMap<K, V> { let r = rand::task_rng(); linear_map_with_capacity_and_keys(r.gen_u64(), r.gen_u64(), initial_capacity) } - pure fn linear_map_with_capacity_and_keys<K: Eq Hash, V>( + pure fn linear_map_with_capacity_and_keys<K:Eq + Hash,V>( k0: u64, k1: u64, initial_capacity: uint) -> LinearMap<K, V> { LinearMap { @@ -74,7 +74,7 @@ pub mod linear { } } - priv impl<K: Hash IterBytes Eq, V> LinearMap<K, V> { + priv impl<K:Hash + IterBytes + Eq,V> LinearMap<K, V> { #[inline(always)] pure fn to_bucket(&self, h: uint) -> uint { // A good hash function with entropy spread over all of the @@ -246,7 +246,7 @@ pub mod linear { } } - impl<K: Hash IterBytes Eq, V> BaseIter<(&K, &V)> for LinearMap<K, V> { + impl<K:Hash + IterBytes + Eq,V> BaseIter<(&K, &V)> for LinearMap<K, V> { /// Visit all key-value pairs pure fn each(&self, blk: fn(&(&self/K, &self/V)) -> bool) { for uint::range(0, self.buckets.len()) |i| { @@ -263,7 +263,7 @@ pub mod linear { } - impl<K: Hash IterBytes Eq, V> Container for LinearMap<K, V> { + impl<K:Hash + IterBytes + Eq,V> Container for LinearMap<K, V> { /// Return the number of elements in the map pure fn len(&self) -> uint { self.size } @@ -271,7 +271,7 @@ pub mod linear { pure fn is_empty(&self) -> bool { self.len() == 0 } } - impl<K: Hash IterBytes Eq, V> Mutable for LinearMap<K, V> { + impl<K:Hash + IterBytes + Eq,V> Mutable for LinearMap<K, V> { /// Clear the map, removing all key-value pairs. fn clear(&mut self) { for uint::range(0, self.buckets.len()) |idx| { @@ -281,7 +281,7 @@ pub mod linear { } } - impl<K: Hash IterBytes Eq, V> Map<K, V> for LinearMap<K, V> { + impl<K:Hash + IterBytes + Eq,V> Map<K, V> for LinearMap<K, V> { /// Return true if the map contains a value for the specified key pure fn contains_key(&self, k: &K) -> bool { match self.bucket_for_key(k) { @@ -333,7 +333,7 @@ pub mod linear { } } - pub impl<K:Hash IterBytes Eq, V> LinearMap<K, V> { + pub impl<K:Hash + IterBytes + Eq,V> LinearMap<K, V> { /// Create an empty LinearMap static fn new() -> LinearMap<K, V> { linear_map_with_capacity(INITIAL_CAPACITY) @@ -457,7 +457,7 @@ pub mod linear { } } - impl<K: Hash IterBytes Eq, V: Eq> Eq for LinearMap<K, V> { + impl<K:Hash + IterBytes + Eq,V:Eq> Eq for LinearMap<K, V> { pure fn eq(&self, other: &LinearMap<K, V>) -> bool { if self.len() != other.len() { return false; } @@ -478,13 +478,13 @@ pub mod linear { priv map: LinearMap<T, ()> } - impl<T: Hash IterBytes Eq> BaseIter<T> for LinearSet<T> { + impl<T:Hash + IterBytes + Eq> BaseIter<T> for LinearSet<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: Hash IterBytes Eq> Eq for LinearSet<T> { + impl<T:Hash + IterBytes + Eq> Eq for LinearSet<T> { pure fn eq(&self, other: &LinearSet<T>) -> bool { self.map == other.map } @@ -493,7 +493,7 @@ pub mod linear { } } - impl<T: Hash IterBytes Eq> Container for LinearSet<T> { + impl<T:Hash + IterBytes + Eq> Container for LinearSet<T> { /// Return the number of elements in the set pure fn len(&self) -> uint { self.map.len() } @@ -501,12 +501,12 @@ pub mod linear { pure fn is_empty(&self) -> bool { self.map.is_empty() } } - impl<T: Hash IterBytes Eq> Mutable for LinearSet<T> { + impl<T:Hash + IterBytes + Eq> Mutable for LinearSet<T> { /// Clear the set, removing all values. fn clear(&mut self) { self.map.clear() } } - impl<T: Hash IterBytes Eq> Set<T> for LinearSet<T> { + impl<T:Hash + IterBytes + Eq> Set<T> for LinearSet<T> { /// Return true if the set contains a value pure fn contains(&self, value: &T) -> bool { self.map.contains_key(value) @@ -575,7 +575,7 @@ pub mod linear { } } - pub impl <T: Hash IterBytes Eq> LinearSet<T> { + pub impl <T:Hash + IterBytes + Eq> LinearSet<T> { /// Create an empty LinearSet static fn new() -> LinearSet<T> { LinearSet{map: LinearMap::new()} } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 6739c5b852e..421eb94a291 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -169,7 +169,7 @@ pub trait ReaderUtil { fn read_i8(&self) -> i8; } -impl<T: Reader> ReaderUtil for T { +impl<T:Reader> ReaderUtil for T { fn read_bytes(&self,len: uint) -> ~[u8] { let mut bytes = vec::with_capacity(len); @@ -193,7 +193,7 @@ impl<T: Reader> ReaderUtil for T { fn read_chars(&self, n: uint) -> ~[char] { // returns the (consumed offset, n_req), appends characters to &chars - fn chars_from_bytes<T: Reader>(bytes: &~[u8], chars: &mut ~[char]) + fn chars_from_bytes<T:Reader>(bytes: &~[u8], chars: &mut ~[char]) -> (uint, uint) { let mut i = 0; let bytes_len = bytes.len(); @@ -460,7 +460,7 @@ struct Wrapper<T, C> { // A forwarding impl of reader that also holds on to a resource for the // duration of its lifetime. // FIXME there really should be a better way to do this // #2004 -impl<R: Reader, C> Reader for Wrapper<R, C> { +impl<R:Reader,C> Reader for Wrapper<R, C> { fn read(&self, bytes: &mut [u8], len: uint) -> uint { self.base.read(bytes, len) } @@ -589,7 +589,7 @@ pub trait Writer { fn get_type(&self) -> WriterType; } -impl<W: Writer, C> Writer for Wrapper<W, C> { +impl<W:Writer,C> Writer for Wrapper<W, C> { fn write(&self, bs: &[const u8]) { self.base.write(bs); } fn seek(&self, off: int, style: SeekStyle) { self.base.seek(off, style); } fn tell(&self) -> uint { self.base.tell() } @@ -890,7 +890,7 @@ pub trait WriterUtil { fn write_i8(&self, n: i8); } -impl<T: Writer> WriterUtil for T { +impl<T:Writer> WriterUtil for T { fn write_char(&self, ch: char) { if ch as uint < 128u { self.write(&[ch as u8]); @@ -1112,7 +1112,7 @@ pub mod fsync { arg: Arg<t>, } - impl<T: Copy> Drop for Res<T> { + impl<T:Copy> Drop for Res<T> { fn finalize(&self) { match self.arg.opt_level { None => (), diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs index 9a8f01baed1..7c4a99133bb 100644 --- a/src/libcore/iter-trait.rs +++ b/src/libcore/iter-trait.rs @@ -60,14 +60,14 @@ impl<A> iter::ExtendedIter<A> for IMPL_T<A> { } -impl<A: Eq> iter::EqIter<A> for IMPL_T<A> { +impl<A:Eq> iter::EqIter<A> for IMPL_T<A> { #[inline(always)] pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } #[inline(always)] pure fn count(&self, x: &A) -> uint { iter::count(self, x) } } -impl<A: Copy> iter::CopyableIter<A> for IMPL_T<A> { +impl<A:Copy> iter::CopyableIter<A> for IMPL_T<A> { #[inline(always)] pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) @@ -80,7 +80,7 @@ impl<A: Copy> iter::CopyableIter<A> for IMPL_T<A> { } } -impl<A: Copy Ord> iter::CopyableOrderedIter<A> for IMPL_T<A> { +impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for IMPL_T<A> { #[inline(always)] pure fn min(&self) -> A { iter::min(self) } #[inline(always)] diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 25cdb11456a..e48edc9c173 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -57,7 +57,7 @@ pub trait CopyableIter<A:Copy> { pure fn find(&self, p: fn(&A) -> bool) -> Option<A>; } -pub trait CopyableOrderedIter<A:Copy Ord> { +pub trait CopyableOrderedIter<A:Copy + Ord> { pure fn min(&self) -> A; pure fn max(&self) -> A; } @@ -211,7 +211,7 @@ pub pure fn repeat(times: uint, blk: fn() -> bool) { } #[inline(always)] -pub pure fn min<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A { +pub pure fn min<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A { match do foldl::<A,Option<A>,IA>(self, None) |a, b| { match a { &Some(ref a_) if *a_ < *b => { @@ -226,7 +226,7 @@ pub pure fn min<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A { } #[inline(always)] -pub pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A { +pub pure fn max<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A { match do foldl::<A,Option<A>,IA>(self, None) |a, b| { match a { &Some(ref a_) if *a_ > *b => { @@ -241,7 +241,7 @@ pub pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: &IA) -> A { } #[inline(always)] -pub pure fn find<A: Copy,IA:BaseIter<A>>(self: &IA, +pub pure fn find<A:Copy,IA:BaseIter<A>>(self: &IA, f: fn(&A) -> bool) -> Option<A> { for self.each |i| { if f(i) { return Some(*i) } @@ -323,7 +323,7 @@ pub pure fn from_fn<T,BT: Buildable<T>>(n_elts: uint, * to the value `t`. */ #[inline(always)] -pub pure fn from_elem<T: Copy,BT: Buildable<T>>(n_elts: uint, +pub pure fn from_elem<T:Copy,BT:Buildable<T>>(n_elts: uint, t: T) -> BT { do Buildable::build_sized(n_elts) |push| { let mut i: uint = 0; @@ -333,7 +333,7 @@ pub pure fn from_elem<T: Copy,BT: Buildable<T>>(n_elts: uint, /// Appending two generic sequences #[inline(always)] -pub pure fn append<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>( +pub pure fn append<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>( lhs: &IT, rhs: &IT) -> BT { let size_opt = lhs.size_hint().chain_ref( |sz1| rhs.size_hint().map(|sz2| *sz1+*sz2)); @@ -346,7 +346,7 @@ pub pure fn append<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>( /// Copies a generic sequence, possibly converting it to a different /// type of sequence. #[inline(always)] -pub pure fn copy_seq<T: Copy,IT: BaseIter<T>,BT: Buildable<T>>( +pub pure fn copy_seq<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>( v: &IT) -> BT { do build_sized_opt(v.size_hint()) |push| { for v.each |x| { push(*x); } diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index e720c2fa108..7038ba07c0d 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -62,7 +62,7 @@ pub enum RoundMode { * ~~~ */ #[inline(always)] -pub pure fn cast<T:NumCast, U:NumCast>(n: T) -> U { +pub pure fn cast<T:NumCast,U:NumCast>(n: T) -> U { NumCast::from(n) } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 13d4ec6e10d..e27b7086bc4 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -85,7 +85,7 @@ pub impl<T:Ord> Ord for Option<T> { } #[inline(always)] -pub pure fn get<T: Copy>(opt: Option<T>) -> T { +pub pure fn get<T:Copy>(opt: Option<T>) -> T { /*! Gets the value out of an option @@ -207,14 +207,14 @@ pub pure fn is_some<T>(opt: &Option<T>) -> bool { } #[inline(always)] -pub pure fn get_or_zero<T: Copy Zero>(opt: Option<T>) -> T { +pub pure fn get_or_zero<T:Copy + Zero>(opt: Option<T>) -> T { //! Returns the contained value or zero (for this type) match opt { Some(copy x) => x, None => Zero::zero() } } #[inline(always)] -pub pure fn get_or_default<T: Copy>(opt: Option<T>, def: T) -> T { +pub pure fn get_or_default<T:Copy>(opt: Option<T>, def: T) -> T { //! Returns the contained value or a default match opt { Some(copy x) => x, None => def } @@ -393,7 +393,7 @@ impl<T> Option<T> { pure fn expect(self, reason: &str) -> T { expect(self, reason) } } -impl<T: Copy> Option<T> { +impl<T:Copy> Option<T> { /** Gets the value out of an option @@ -421,7 +421,7 @@ impl<T: Copy> Option<T> { } } -impl<T: Copy Zero> Option<T> { +impl<T:Copy + Zero> Option<T> { #[inline(always)] pure fn get_or_zero(self) -> T { get_or_zero(self) } } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index f0108fe85b7..b3e32fc6b6c 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -189,7 +189,7 @@ impl PacketHeader { reinterpret_cast(&self.buffer) } - fn set_buffer<T: Owned>(b: ~Buffer<T>) { + fn set_buffer<T:Owned>(b: ~Buffer<T>) { unsafe { self.buffer = reinterpret_cast(&b); } @@ -207,14 +207,14 @@ pub trait HasBuffer { fn set_buffer(b: *libc::c_void); } -impl<T: Owned> HasBuffer for Packet<T> { +impl<T:Owned> HasBuffer for Packet<T> { fn set_buffer(b: *libc::c_void) { self.header.buffer = b; } } #[doc(hidden)] -pub fn mk_packet<T: Owned>() -> Packet<T> { +pub fn mk_packet<T:Owned>() -> Packet<T> { Packet { header: PacketHeader(), payload: None, @@ -246,7 +246,7 @@ pub fn packet<T>() -> *Packet<T> { } #[doc(hidden)] -pub fn entangle_buffer<T: Owned, Tstart: Owned>( +pub fn entangle_buffer<T:Owned,Tstart:Owned>( buffer: ~Buffer<T>, init: fn(*libc::c_void, x: &T) -> *Packet<Tstart>) -> (SendPacketBuffered<Tstart, T>, RecvPacketBuffered<Tstart, T>) @@ -432,7 +432,7 @@ pub fn send<T,Tbuffer>(p: SendPacketBuffered<T,Tbuffer>, payload: T) -> bool { Fails if the sender closes the connection. */ -pub fn recv<T: Owned, Tbuffer: Owned>( +pub fn recv<T:Owned,Tbuffer:Owned>( p: RecvPacketBuffered<T, Tbuffer>) -> T { try_recv(p).expect("connection closed") } @@ -443,7 +443,7 @@ Returns `None` if the sender has closed the connection without sending a message, or `Some(T)` if a message was received. */ -pub fn try_recv<T: Owned, Tbuffer: Owned>(p: RecvPacketBuffered<T, Tbuffer>) +pub fn try_recv<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>) -> Option<T> { let p_ = p.unwrap(); @@ -553,7 +553,7 @@ pub fn try_recv<T: Owned, Tbuffer: Owned>(p: RecvPacketBuffered<T, Tbuffer>) } /// Returns true if messages are available. -pub pure fn peek<T: Owned, Tb: Owned>(p: &RecvPacketBuffered<T, Tb>) -> bool { +pub pure fn peek<T:Owned,Tb:Owned>(p: &RecvPacketBuffered<T, Tb>) -> bool { match unsafe {(*p.header()).state} { Empty | Terminated => false, Blocked => fail!(~"peeking on blocked packet"), @@ -561,14 +561,14 @@ pub pure fn peek<T: Owned, Tb: Owned>(p: &RecvPacketBuffered<T, Tb>) -> bool { } } -impl<T: Owned, Tb: Owned> Peekable<T> for RecvPacketBuffered<T, Tb> { +impl<T:Owned,Tb:Owned> Peekable<T> for RecvPacketBuffered<T, Tb> { pure fn peek() -> bool { peek(&self) } } #[doc(hidden)] -fn sender_terminate<T: Owned>(p: *Packet<T>) { +fn sender_terminate<T:Owned>(p: *Packet<T>) { let p = unsafe { &*p }; match swap_state_rel(&mut p.header.state, Terminated) { Empty => { @@ -599,7 +599,7 @@ fn sender_terminate<T: Owned>(p: *Packet<T>) { } #[doc(hidden)] -fn receiver_terminate<T: Owned>(p: *Packet<T>) { +fn receiver_terminate<T:Owned>(p: *Packet<T>) { let p = unsafe { &*p }; match swap_state_rel(&mut p.header.state, Terminated) { Empty => { @@ -632,7 +632,7 @@ that vector. The index points to an endpoint that has either been closed by the sender or has a message waiting to be received. */ -fn wait_many<T: Selectable>(pkts: &[T]) -> uint { +fn wait_many<T:Selectable>(pkts: &[T]) -> uint { let this = unsafe { rustrt::rust_get_task() }; unsafe { @@ -714,7 +714,7 @@ Sometimes messages will be available on both endpoints at once. In this case, `select2` may return either `left` or `right`. */ -pub fn select2<A: Owned, Ab: Owned, B: Owned, Bb: Owned>( +pub fn select2<A:Owned,Ab:Owned,B:Owned,Bb:Owned>( a: RecvPacketBuffered<A, Ab>, b: RecvPacketBuffered<B, Bb>) -> Either<(Option<A>, RecvPacketBuffered<B, Bb>), @@ -739,12 +739,12 @@ impl Selectable for *PacketHeader { } /// Returns the index of an endpoint that is ready to receive. -pub fn selecti<T: Selectable>(endpoints: &[T]) -> uint { +pub fn selecti<T:Selectable>(endpoints: &[T]) -> uint { wait_many(endpoints) } /// Returns 0 or 1 depending on which endpoint is ready to receive -pub fn select2i<A: Selectable, B: Selectable>(a: &A, b: &B) -> +pub fn select2i<A:Selectable,B:Selectable>(a: &A, b: &B) -> Either<(), ()> { match wait_many([a.header(), b.header()]) { 0 => Left(()), @@ -757,7 +757,7 @@ pub fn select2i<A: Selectable, B: Selectable>(a: &A, b: &B) -> list of the remaining endpoints. */ -pub fn select<T: Owned, Tb: Owned>(endpoints: ~[RecvPacketBuffered<T, Tb>]) +pub fn select<T:Owned,Tb:Owned>(endpoints: ~[RecvPacketBuffered<T, Tb>]) -> (uint, Option<T>, ~[RecvPacketBuffered<T, Tb>]) { let ready = wait_many(endpoints.map(|p| p.header())); @@ -852,7 +852,7 @@ pub struct RecvPacketBuffered<T, Tbuffer> { mut buffer: Option<BufferResource<Tbuffer>>, } -impl<T:Owned, Tbuffer:Owned> ::ops::Drop for RecvPacketBuffered<T,Tbuffer> { +impl<T:Owned,Tbuffer:Owned> ::ops::Drop for RecvPacketBuffered<T,Tbuffer> { fn finalize(&self) { //if self.p != none { // debug!("drop recv %?", option::get(self.p)); @@ -869,7 +869,7 @@ impl<T:Owned, Tbuffer:Owned> ::ops::Drop for RecvPacketBuffered<T,Tbuffer> { } } -impl<T: Owned, Tbuffer: Owned> RecvPacketBuffered<T, Tbuffer> { +impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> { fn unwrap() -> *Packet<T> { let mut p = None; p <-> self.p; @@ -884,7 +884,7 @@ impl<T: Owned, Tbuffer: Owned> RecvPacketBuffered<T, Tbuffer> { } } -impl<T: Owned, Tbuffer: Owned> Selectable for RecvPacketBuffered<T, Tbuffer> { +impl<T:Owned,Tbuffer:Owned> Selectable for RecvPacketBuffered<T, Tbuffer> { pure fn header() -> *PacketHeader { match self.p { Some(packet) => unsafe { @@ -923,7 +923,7 @@ endpoint. The send endpoint is returned to the caller and the receive endpoint is passed to the new task. */ -pub fn spawn_service<T: Owned, Tb: Owned>( +pub fn spawn_service<T:Owned,Tb:Owned>( init: extern fn() -> (SendPacketBuffered<T, Tb>, RecvPacketBuffered<T, Tb>), service: fn~(v: RecvPacketBuffered<T, Tb>)) @@ -947,7 +947,7 @@ pub fn spawn_service<T: Owned, Tb: Owned>( receive state. */ -pub fn spawn_service_recv<T: Owned, Tb: Owned>( +pub fn spawn_service_recv<T:Owned,Tb:Owned>( init: extern fn() -> (RecvPacketBuffered<T, Tb>, SendPacketBuffered<T, Tb>), service: fn~(v: SendPacketBuffered<T, Tb>)) @@ -970,7 +970,7 @@ pub fn spawn_service_recv<T: Owned, Tb: Owned>( // Streams - Make pipes a little easier in general. proto! streamp ( - Open:send<T: Owned> { + Open:send<T:Owned> { data(T) -> Open<T> } ) @@ -1036,7 +1036,7 @@ pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) { (Port_(Port_ { endp: Some(s) }), Chan_(Chan_{ endp: Some(c) })) } -impl<T: Owned> GenericChan<T> for Chan<T> { +impl<T:Owned> GenericChan<T> for Chan<T> { fn send(x: T) { let mut endp = None; endp <-> self.endp; @@ -1045,7 +1045,7 @@ impl<T: Owned> GenericChan<T> for Chan<T> { } } -impl<T: Owned> GenericSmartChan<T> for Chan<T> { +impl<T:Owned> GenericSmartChan<T> for Chan<T> { fn try_send(x: T) -> bool { let mut endp = None; @@ -1060,7 +1060,7 @@ impl<T: Owned> GenericSmartChan<T> for Chan<T> { } } -impl<T: Owned> GenericPort<T> for Port<T> { +impl<T:Owned> GenericPort<T> for Port<T> { fn recv() -> T { let mut endp = None; endp <-> self.endp; @@ -1082,7 +1082,7 @@ impl<T: Owned> GenericPort<T> for Port<T> { } } -impl<T: Owned> Peekable<T> for Port<T> { +impl<T:Owned> Peekable<T> for Port<T> { pure fn peek() -> bool { unsafe { let mut endp = None; @@ -1097,7 +1097,7 @@ impl<T: Owned> Peekable<T> for Port<T> { } } -impl<T: Owned> Selectable for Port<T> { +impl<T:Owned> Selectable for Port<T> { pure fn header() -> *PacketHeader { unsafe { match self.endp { @@ -1113,13 +1113,13 @@ pub struct PortSet<T> { mut ports: ~[pipes::Port<T>], } -pub fn PortSet<T: Owned>() -> PortSet<T>{ +pub fn PortSet<T:Owned>() -> PortSet<T>{ PortSet { ports: ~[] } } -impl<T: Owned> PortSet<T> { +impl<T:Owned> PortSet<T> { fn add(port: pipes::Port<T>) { self.ports.push(port) @@ -1132,7 +1132,7 @@ impl<T: Owned> PortSet<T> { } } -impl<T: Owned> GenericPort<T> for PortSet<T> { +impl<T:Owned> GenericPort<T> for PortSet<T> { fn try_recv() -> Option<T> { let mut result = None; @@ -1162,7 +1162,7 @@ impl<T: Owned> GenericPort<T> for PortSet<T> { } -impl<T: Owned> Peekable<T> for PortSet<T> { +impl<T:Owned> Peekable<T> for PortSet<T> { pure fn peek() -> bool { // It'd be nice to use self.port.each, but that version isn't // pure. @@ -1176,7 +1176,7 @@ impl<T: Owned> Peekable<T> for PortSet<T> { /// A channel that can be shared between many senders. pub type SharedChan<T> = private::Exclusive<Chan<T>>; -impl<T: Owned> GenericChan<T> for SharedChan<T> { +impl<T:Owned> GenericChan<T> for SharedChan<T> { fn send(x: T) { let mut xx = Some(x); do self.with_imm |chan| { @@ -1187,7 +1187,7 @@ impl<T: Owned> GenericChan<T> for SharedChan<T> { } } -impl<T: Owned> GenericSmartChan<T> for SharedChan<T> { +impl<T:Owned> GenericSmartChan<T> for SharedChan<T> { fn try_send(x: T) -> bool { let mut xx = Some(x); do self.with_imm |chan| { @@ -1204,7 +1204,7 @@ pub fn SharedChan<T:Owned>(c: Chan<T>) -> SharedChan<T> { } /// Receive a message from one of two endpoints. -pub trait Select2<T: Owned, U: Owned> { +pub trait Select2<T:Owned,U:Owned> { /// Receive a message or return `None` if a connection closes. fn try_select() -> Either<Option<T>, Option<U>>; /// Receive a message or fail if a connection closes. @@ -1247,17 +1247,17 @@ pub type ChanOne<T> = oneshot::client::Oneshot<T>; pub type PortOne<T> = oneshot::server::Oneshot<T>; /// Initialiase a (send-endpoint, recv-endpoint) oneshot pipe pair. -pub fn oneshot<T: Owned>() -> (PortOne<T>, ChanOne<T>) { +pub fn oneshot<T:Owned>() -> (PortOne<T>, ChanOne<T>) { let (chan, port) = oneshot::init(); (port, chan) } -impl<T: Owned> PortOne<T> { +impl<T:Owned> PortOne<T> { fn recv(self) -> T { recv_one(self) } fn try_recv(self) -> Option<T> { try_recv_one(self) } } -impl<T: Owned> ChanOne<T> { +impl<T:Owned> ChanOne<T> { fn send(self, data: T) { send_one(self, data) } fn try_send(self, data: T) -> bool { try_send_one(self, data) } } @@ -1266,13 +1266,13 @@ impl<T: Owned> ChanOne<T> { * Receive a message from a oneshot pipe, failing if the connection was * closed. */ -pub fn recv_one<T: Owned>(port: PortOne<T>) -> T { +pub fn recv_one<T:Owned>(port: PortOne<T>) -> T { let oneshot::send(message) = recv(port); message } /// Receive a message from a oneshot pipe unless the connection was closed. -pub fn try_recv_one<T: Owned> (port: PortOne<T>) -> Option<T> { +pub fn try_recv_one<T:Owned> (port: PortOne<T>) -> Option<T> { let message = try_recv(port); if message.is_none() { None } @@ -1283,7 +1283,7 @@ pub fn try_recv_one<T: Owned> (port: PortOne<T>) -> Option<T> { } /// Send a message on a oneshot pipe, failing if the connection was closed. -pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) { +pub fn send_one<T:Owned>(chan: ChanOne<T>, data: T) { oneshot::client::send(chan, data); } @@ -1291,7 +1291,7 @@ pub fn send_one<T: Owned>(chan: ChanOne<T>, data: T) { * Send a message on a oneshot pipe, or return false if the connection was * closed. */ -pub fn try_send_one<T: Owned>(chan: ChanOne<T>, data: T) +pub fn try_send_one<T:Owned>(chan: ChanOne<T>, data: T) -> bool { oneshot::client::try_send(chan, data).is_some() } diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 5b69c348c15..465ddb361ab 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -170,7 +170,7 @@ fn ArcDestruct<T>(data: *libc::c_void) -> ArcDestruct<T> { } } -pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>) +pub unsafe fn unwrap_shared_mutable_state<T:Owned>(rc: SharedMutableState<T>) -> T { struct DeathThroes<T> { mut ptr: Option<~ArcData<T>>, @@ -246,7 +246,7 @@ pub unsafe fn unwrap_shared_mutable_state<T: Owned>(rc: SharedMutableState<T>) */ pub type SharedMutableState<T> = ArcDestruct<T>; -pub unsafe fn shared_mutable_state<T: Owned>(data: T) -> +pub unsafe fn shared_mutable_state<T:Owned>(data: T) -> SharedMutableState<T> { let data = ~ArcData { count: 1, unwrapper: 0, data: Some(data) }; unsafe { @@ -256,7 +256,7 @@ pub unsafe fn shared_mutable_state<T: Owned>(data: T) -> } #[inline(always)] -pub unsafe fn get_shared_mutable_state<T: Owned>( +pub unsafe fn get_shared_mutable_state<T:Owned>( rc: *SharedMutableState<T>) -> *mut T { unsafe { @@ -268,7 +268,7 @@ pub unsafe fn get_shared_mutable_state<T: Owned>( } } #[inline(always)] -pub unsafe fn get_shared_immutable_state<T: Owned>( +pub unsafe fn get_shared_immutable_state<T:Owned>( rc: &a/SharedMutableState<T>) -> &a/T { unsafe { let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data); @@ -280,7 +280,7 @@ pub unsafe fn get_shared_immutable_state<T: Owned>( } } -pub unsafe fn clone_shared_mutable_state<T: Owned>(rc: &SharedMutableState<T>) +pub unsafe fn clone_shared_mutable_state<T:Owned>(rc: &SharedMutableState<T>) -> SharedMutableState<T> { unsafe { let ptr: ~ArcData<T> = cast::reinterpret_cast(&(*rc).data); @@ -291,7 +291,7 @@ pub unsafe fn clone_shared_mutable_state<T: Owned>(rc: &SharedMutableState<T>) ArcDestruct((*rc).data) } -impl<T: Owned> Clone for SharedMutableState<T> { +impl<T:Owned> Clone for SharedMutableState<T> { fn clone(&self) -> SharedMutableState<T> { unsafe { clone_shared_mutable_state(self) @@ -353,21 +353,21 @@ struct ExData<T> { lock: LittleLock, mut failed: bool, mut data: T, } */ pub struct Exclusive<T> { x: SharedMutableState<ExData<T>> } -pub fn exclusive<T:Owned >(user_data: T) -> Exclusive<T> { +pub fn exclusive<T:Owned>(user_data: T) -> Exclusive<T> { let data = ExData { lock: LittleLock(), mut failed: false, mut data: user_data }; Exclusive { x: unsafe { shared_mutable_state(data) } } } -impl<T: Owned> Clone for Exclusive<T> { +impl<T:Owned> Clone for Exclusive<T> { // Duplicate an exclusive ARC, as std::arc::clone. fn clone(&self) -> Exclusive<T> { Exclusive { x: unsafe { clone_shared_mutable_state(&self.x) } } } } -impl<T: Owned> Exclusive<T> { +impl<T:Owned> Exclusive<T> { // Exactly like std::arc::mutex_arc,access(), but with the little_lock // instead of a proper mutex. Same reason for being unsafe. // @@ -400,7 +400,7 @@ impl<T: Owned> Exclusive<T> { } // FIXME(#3724) make this a by-move method on the exclusive -pub fn unwrap_exclusive<T: Owned>(arc: Exclusive<T>) -> T { +pub fn unwrap_exclusive<T:Owned>(arc: Exclusive<T>) -> T { let Exclusive { x: x } = arc; let inner = unsafe { unwrap_shared_mutable_state(x) }; let ExData { data: data, _ } = inner; diff --git a/src/libcore/private/global.rs b/src/libcore/private/global.rs index 621ead48abc..10e4cd9ddb0 100644 --- a/src/libcore/private/global.rs +++ b/src/libcore/private/global.rs @@ -43,7 +43,7 @@ use uint; pub type GlobalDataKey<T> = &fn(v: T); -pub unsafe fn global_data_clone_create<T: Owned Clone>( +pub unsafe fn global_data_clone_create<T:Owned + Clone>( key: GlobalDataKey<T>, create: &fn() -> ~T) -> T { /*! * Clone a global value or, if it has not been created, @@ -59,7 +59,7 @@ pub unsafe fn global_data_clone_create<T: Owned Clone>( global_data_clone_create_(key_ptr(key), create) } -unsafe fn global_data_clone_create_<T: Owned Clone>( +unsafe fn global_data_clone_create_<T:Owned + Clone>( key: uint, create: &fn() -> ~T) -> T { let mut clone_value: Option<T> = None; @@ -79,13 +79,13 @@ unsafe fn global_data_clone_create_<T: Owned Clone>( return clone_value.unwrap(); } -unsafe fn global_data_modify<T: Owned>( +unsafe fn global_data_modify<T:Owned>( key: GlobalDataKey<T>, op: &fn(Option<~T>) -> Option<~T>) { global_data_modify_(key_ptr(key), op) } -unsafe fn global_data_modify_<T: Owned>( +unsafe fn global_data_modify_<T:Owned>( key: uint, op: &fn(Option<~T>) -> Option<~T>) { let mut old_dtor = None; @@ -124,7 +124,7 @@ unsafe fn global_data_modify_<T: Owned>( } } -pub unsafe fn global_data_clone<T: Owned Clone>( +pub unsafe fn global_data_clone<T:Owned + Clone>( key: GlobalDataKey<T>) -> Option<T> { let mut maybe_clone: Option<T> = None; do global_data_modify(key) |current| { @@ -220,7 +220,7 @@ fn get_global_state() -> Exclusive<GlobalState> { } } -fn key_ptr<T: Owned>(key: GlobalDataKey<T>) -> uint { +fn key_ptr<T:Owned>(key: GlobalDataKey<T>) -> uint { unsafe { let closure: Closure = reinterpret_cast(&key); return transmute(closure.code); diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 79dd29604e4..a88b8346516 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -109,7 +109,7 @@ impl Rand for bool { } } -impl<T: Rand> Rand for Option<T> { +impl<T:Rand> Rand for Option<T> { static fn rand(rng: rand::Rng) -> Option<T> { if rng.gen_bool() { Some(Rand::rand(rng)) } else { None } @@ -143,7 +143,7 @@ pub struct Weighted<T> { /// Extension methods for random number generators impl Rng { /// Return a random value for a Rand type - fn gen<T: Rand>() -> T { + fn gen<T:Rand>() -> T { Rand::rand(self) } @@ -302,7 +302,7 @@ impl Rng { * Choose an item respecting the relative weights, failing if the sum of * the weights is 0 */ - fn choose_weighted<T: Copy>(v : &[Weighted<T>]) -> T { + fn choose_weighted<T:Copy>(v : &[Weighted<T>]) -> T { self.choose_weighted_option(v).get() } diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index 8983c63f42a..ed7e485678e 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -41,11 +41,11 @@ pub fn align(size: uint, align: uint) -> uint { pub struct MovePtrAdaptor<V> { inner: V } -pub fn MovePtrAdaptor<V: TyVisitor MovePtr>(v: V) -> MovePtrAdaptor<V> { +pub fn MovePtrAdaptor<V:TyVisitor + MovePtr>(v: V) -> MovePtrAdaptor<V> { MovePtrAdaptor { inner: v } } -impl<V: TyVisitor MovePtr> MovePtrAdaptor<V> { +impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> { #[inline(always)] fn bump(sz: uint) { do self.inner.move_ptr() |p| { @@ -72,7 +72,7 @@ impl<V: TyVisitor MovePtr> MovePtrAdaptor<V> { } /// Abstract type-directed pointer-movement using the MovePtr trait -impl<V: TyVisitor MovePtr> TyVisitor for MovePtrAdaptor<V> { +impl<V:TyVisitor + MovePtr> TyVisitor for MovePtrAdaptor<V> { fn visit_bot(&self) -> bool { self.align_to::<()>(); if ! self.inner.visit_bot() { return false; } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 64c62c92584..b03eaeab3e0 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -37,7 +37,7 @@ pub enum Result<T, U> { * If the result is an error */ #[inline(always)] -pub pure fn get<T: Copy, U>(res: &Result<T, U>) -> T { +pub pure fn get<T:Copy,U>(res: &Result<T, U>) -> T { match *res { Ok(copy t) => t, Err(ref the_err) => unsafe { @@ -100,7 +100,7 @@ pub pure fn is_err<T, U>(res: &Result<T, U>) -> bool { * result variants are converted to `either::left`. */ #[inline(always)] -pub pure fn to_either<T: Copy, U: Copy>(res: &Result<U, T>) +pub pure fn to_either<T:Copy,U:Copy>(res: &Result<U, T>) -> Either<T, U> { match *res { Ok(copy res) => either::Right(res), @@ -220,7 +220,7 @@ pub pure fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: fn(&T) -> U) * successful result while handling an error. */ #[inline(always)] -pub pure fn map_err<T: Copy, E, F: Copy>(res: &Result<T, E>, op: fn(&E) -> F) +pub pure fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: fn(&E) -> F) -> Result<T, F> { match *res { Ok(copy t) => Ok(t), @@ -261,7 +261,7 @@ impl<T, E> Result<T, E> { } } -impl<T: Copy, E> Result<T, E> { +impl<T:Copy,E> Result<T, E> { #[inline(always)] pure fn get(&self) -> T { get(self) } diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index fe37a2e155f..ae101faaf02 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -51,7 +51,7 @@ pub type LocalDataKey<T> = &fn(v: @T); * Remove a task-local data value from the table, returning the * reference that was originally created to insert it. */ -pub unsafe fn local_data_pop<T: Durable>( +pub unsafe fn local_data_pop<T:Durable>( key: LocalDataKey<T>) -> Option<@T> { local_pop(rt::rust_get_task(), key) @@ -60,7 +60,7 @@ pub unsafe fn local_data_pop<T: Durable>( * Retrieve a task-local data value. It will also be kept alive in the * table until explicitly removed. */ -pub unsafe fn local_data_get<T: Durable>( +pub unsafe fn local_data_get<T:Durable>( key: LocalDataKey<T>) -> Option<@T> { local_get(rt::rust_get_task(), key) @@ -69,7 +69,7 @@ pub unsafe fn local_data_get<T: Durable>( * Store a value in task-local data. If this key already has a value, * that value is overwritten (and its destructor is run). */ -pub unsafe fn local_data_set<T: Durable>( +pub unsafe fn local_data_set<T:Durable>( key: LocalDataKey<T>, data: @T) { local_set(rt::rust_get_task(), key, data) @@ -78,7 +78,7 @@ pub unsafe fn local_data_set<T: Durable>( * Modify a task-local data value. If the function returns 'None', the * data is removed (and its reference dropped). */ -pub unsafe fn local_data_modify<T: Durable>( +pub unsafe fn local_data_modify<T:Durable>( key: LocalDataKey<T>, modify_fn: fn(Option<@T>) -> Option<@T>) { diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 949c36545dd..3ac457b23d1 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -26,7 +26,7 @@ use rt::rust_task; type rust_task = libc::c_void; pub trait LocalData { } -impl<T: Durable> LocalData for @T { } +impl<T:Durable> LocalData for @T { } impl Eq for LocalData { pure fn eq(&self, other: &@LocalData) -> bool { @@ -79,7 +79,7 @@ unsafe fn get_task_local_map(task: *rust_task) -> TaskLocalMap { } } -unsafe fn key_to_key_value<T: Durable>( +unsafe fn key_to_key_value<T:Durable>( key: LocalDataKey<T>) -> *libc::c_void { // Keys are closures, which are (fnptr,envptr) pairs. Use fnptr. @@ -89,7 +89,7 @@ unsafe fn key_to_key_value<T: Durable>( } // If returning Some(..), returns with @T with the map's reference. Careful! -unsafe fn local_data_lookup<T: Durable>( +unsafe fn local_data_lookup<T:Durable>( map: TaskLocalMap, key: LocalDataKey<T>) -> Option<(uint, *libc::c_void)> { @@ -107,7 +107,7 @@ unsafe fn local_data_lookup<T: Durable>( } } -unsafe fn local_get_helper<T: Durable>( +unsafe fn local_get_helper<T:Durable>( task: *rust_task, key: LocalDataKey<T>, do_pop: bool) -> Option<@T> { @@ -129,21 +129,21 @@ unsafe fn local_get_helper<T: Durable>( } -pub unsafe fn local_pop<T: Durable>( +pub unsafe fn local_pop<T:Durable>( task: *rust_task, key: LocalDataKey<T>) -> Option<@T> { local_get_helper(task, key, true) } -pub unsafe fn local_get<T: Durable>( +pub unsafe fn local_get<T:Durable>( task: *rust_task, key: LocalDataKey<T>) -> Option<@T> { local_get_helper(task, key, false) } -pub unsafe fn local_set<T: Durable>( +pub unsafe fn local_set<T:Durable>( task: *rust_task, key: LocalDataKey<T>, data: @T) { let map = get_task_local_map(task); @@ -175,7 +175,7 @@ pub unsafe fn local_set<T: Durable>( } } -pub unsafe fn local_modify<T: Durable>( +pub unsafe fn local_modify<T:Durable>( task: *rust_task, key: LocalDataKey<T>, modify_fn: fn(Option<@T>) -> Option<@T>) { diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 4b15d1f76c9..54dfa7459a1 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -396,7 +396,7 @@ impl TaskBuilder { spawn::spawn_raw(opts, (x.gen_body)(f)); } /// Runs a task, while transfering ownership of one argument to the child. - fn spawn_with<A: Owned>(arg: A, f: fn~(v: A)) { + fn spawn_with<A:Owned>(arg: A, f: fn~(v: A)) { let arg = ~mut Some(arg); do self.spawn || { f(option::swap_unwrap(arg)) @@ -416,7 +416,7 @@ impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - fn try<T: Owned>(f: fn~() -> T) -> Result<T,()> { + fn try<T:Owned>(f: fn~() -> T) -> Result<T,()> { let (po, ch) = stream::<T>(); let mut result = None; diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs index 10efa9196a7..4b2cd3c2fab 100644 --- a/src/libcore/to_bytes.rs +++ b/src/libcore/to_bytes.rs @@ -197,7 +197,7 @@ impl IterBytes for int { } } -impl<A: IterBytes> IterBytes for &[A] { +impl<A:IterBytes> IterBytes for &[A] { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { for (*self).each |elt| { @@ -208,7 +208,7 @@ impl<A: IterBytes> IterBytes for &[A] { } } -impl<A: IterBytes, B: IterBytes> IterBytes for (A,B) { +impl<A:IterBytes,B:IterBytes> IterBytes for (A,B) { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { match *self { @@ -219,7 +219,7 @@ impl<A: IterBytes, B: IterBytes> IterBytes for (A,B) { } } -impl<A: IterBytes, B: IterBytes, C: IterBytes> IterBytes for (A,B,C) { +impl<A:IterBytes,B:IterBytes,C:IterBytes> IterBytes for (A,B,C) { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { match *self { @@ -235,21 +235,21 @@ pure fn borrow<A>(a: &x/[A]) -> &x/[A] { a } -impl<A: IterBytes> IterBytes for ~[A] { +impl<A:IterBytes> IterBytes for ~[A] { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { borrow(*self).iter_bytes(lsb0, f) } } -impl<A: IterBytes> IterBytes for @[A] { +impl<A:IterBytes> IterBytes for @[A] { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { borrow(*self).iter_bytes(lsb0, f) } } -pub pure fn iter_bytes_2<A: IterBytes, B: IterBytes>(a: &A, b: &B, +pub pure fn iter_bytes_2<A:IterBytes,B:IterBytes>(a: &A, b: &B, lsb0: bool, z: Cb) { let mut flag = true; a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); @@ -379,7 +379,7 @@ impl IterBytes for @str { } } -impl<A: IterBytes> IterBytes for Option<A> { +impl<A:IterBytes> IterBytes for Option<A> { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { match *self { @@ -389,21 +389,21 @@ impl<A: IterBytes> IterBytes for Option<A> { } } -impl<A: IterBytes> IterBytes for &A { +impl<A:IterBytes> IterBytes for &A { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { (**self).iter_bytes(lsb0, f); } } -impl<A: IterBytes> IterBytes for @A { +impl<A:IterBytes> IterBytes for @A { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { (**self).iter_bytes(lsb0, f); } } -impl<A: IterBytes> IterBytes for ~A { +impl<A:IterBytes> IterBytes for ~A { #[inline(always)] pure fn iter_bytes(&self, lsb0: bool, f: Cb) { (**self).iter_bytes(lsb0, f); @@ -424,7 +424,7 @@ trait ToBytes { fn to_bytes(&self, lsb0: bool) -> ~[u8]; } -impl<A: IterBytes> ToBytes for A { +impl<A:IterBytes> ToBytes for A { fn to_bytes(&self, lsb0: bool) -> ~[u8] { do io::with_bytes_writer |wr| { for self.iter_bytes(lsb0) |bytes| { diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index 4cccc1d2638..0145adc77b8 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -45,7 +45,7 @@ impl ToStr for @str { // FIXME #4898: impl for one-tuples -impl<A: ToStr, B: ToStr> ToStr for (A, B) { +impl<A:ToStr,B:ToStr> ToStr for (A, B) { #[inline(always)] pure fn to_str(&self) -> ~str { // FIXME(#4760): this causes an llvm assertion @@ -57,7 +57,7 @@ impl<A: ToStr, B: ToStr> ToStr for (A, B) { } } } -impl<A: ToStr, B: ToStr, C: ToStr> ToStr for (A, B, C) { +impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) { #[inline(always)] pure fn to_str(&self) -> ~str { // FIXME(#4760): this causes an llvm assertion @@ -74,7 +74,7 @@ impl<A: ToStr, B: ToStr, C: ToStr> ToStr for (A, B, C) { } } -impl<A: ToStr> ToStr for ~[A] { +impl<A:ToStr> ToStr for ~[A] { #[inline(always)] pure fn to_str(&self) -> ~str { unsafe { @@ -94,11 +94,11 @@ impl<A: ToStr> ToStr for ~[A] { } } -impl<A: ToStr> ToStr for @A { +impl<A:ToStr> ToStr for @A { #[inline(always)] pure fn to_str(&self) -> ~str { ~"@" + (**self).to_str() } } -impl<A: ToStr> ToStr for ~A { +impl<A:ToStr> ToStr for ~A { #[inline(always)] pure fn to_str(&self) -> ~str { ~"~" + (**self).to_str() } } diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index e49c1d26a06..dde7d718c13 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -20,7 +20,7 @@ pub trait CopyableTuple<T, U> { pure fn swap() -> (U, T); } -impl<T: Copy, U: Copy> CopyableTuple<T, U> for (T, U) { +impl<T:Copy,U:Copy> CopyableTuple<T, U> for (T, U) { /// Return the first element of self #[inline(always)] @@ -70,7 +70,7 @@ pub trait ExtendedTupleOps<A,B> { fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C]; } -impl<A: Copy, B: Copy> ExtendedTupleOps<A,B> for (&[A], &[B]) { +impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&[A], &[B]) { #[inline(always)] fn zip(&self) -> ~[(A, B)] { match *self { @@ -90,7 +90,7 @@ impl<A: Copy, B: Copy> ExtendedTupleOps<A,B> for (&[A], &[B]) { } } -impl<A: Copy, B: Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) { +impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) { #[inline(always)] fn zip(&self) -> ~[(A, B)] { @@ -114,7 +114,7 @@ impl<A: Copy, B: Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) { // FIXME #4898: impl for one-tuples #[cfg(notest)] -impl<A: Eq, B: Eq> Eq for (A, B) { +impl<A:Eq,B:Eq> Eq for (A, B) { #[inline(always)] pure fn eq(&self, other: &(A, B)) -> bool { match (*self) { @@ -130,7 +130,7 @@ impl<A: Eq, B: Eq> Eq for (A, B) { } #[cfg(notest)] -impl<A: Ord, B: Ord> Ord for (A, B) { +impl<A:Ord,B:Ord> Ord for (A, B) { #[inline(always)] pure fn lt(&self, other: &(A, B)) -> bool { match (*self) { @@ -155,7 +155,7 @@ impl<A: Ord, B: Ord> Ord for (A, B) { } #[cfg(notest)] -impl<A: Eq, B: Eq, C: Eq> Eq for (A, B, C) { +impl<A:Eq,B:Eq,C:Eq> Eq for (A, B, C) { #[inline(always)] pure fn eq(&self, other: &(A, B, C)) -> bool { match (*self) { @@ -172,7 +172,7 @@ impl<A: Eq, B: Eq, C: Eq> Eq for (A, B, C) { } #[cfg(notest)] -impl<A: Ord, B: Ord, C: Ord> Ord for (A, B, C) { +impl<A:Ord,B:Ord,C:Ord> Ord for (A, B, C) { #[inline(always)] pure fn lt(&self, other: &(A, B, C)) -> bool { match (*self) { diff --git a/src/libcore/util.rs b/src/libcore/util.rs index eea172a43ce..629c4a3291c 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -28,7 +28,7 @@ pub pure fn ignore<T>(_x: T) { } /// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the /// original value of `*ptr`. #[inline(always)] -pub fn with<T: Copy, R>( +pub fn with<T:Copy,R>( ptr: &mut T, new_value: T, op: &fn() -> R) -> R diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index b55a3bee8b0..a7edd0ea9c3 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -135,12 +135,12 @@ pub pure fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> ~[T] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pub pure fn from_elem<T: Copy>(n_elts: uint, t: T) -> ~[T] { +pub pure fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[T] { from_fn(n_elts, |_i| copy t) } /// Creates a new unique vector with the same contents as the slice -pub pure fn from_slice<T: Copy>(t: &[T]) -> ~[T] { +pub pure fn from_slice<T:Copy>(t: &[T]) -> ~[T] { from_fn(t.len(), |i| t[i]) } @@ -216,10 +216,10 @@ pub pure fn cast_from_mut<T>(v: ~[mut T]) -> ~[T] { // Accessors /// Returns the first element of a vector -pub pure fn head<T: Copy>(v: &[const T]) -> T { v[0] } +pub pure fn head<T:Copy>(v: &[const T]) -> T { v[0] } /// Returns a vector containing all but the first element of a slice -pub pure fn tail<T: Copy>(v: &[const T]) -> ~[T] { +pub pure fn tail<T:Copy>(v: &[const T]) -> ~[T] { slice(v, 1u, len(v)).to_vec() } @@ -227,18 +227,18 @@ pub pure fn tail<T: Copy>(v: &[const T]) -> ~[T] { * Returns a vector containing all but the first `n` \ * elements of a slice */ -pub pure fn tailn<T: Copy>(v: &[const T], n: uint) -> ~[T] { +pub pure fn tailn<T:Copy>(v: &[const T], n: uint) -> ~[T] { slice(v, n, len(v)).to_vec() } /// Returns a vector containing all but the last element of a slice -pub pure fn init<T: Copy>(v: &[const T]) -> ~[T] { +pub pure fn init<T:Copy>(v: &[const T]) -> ~[T] { assert len(v) != 0u; slice(v, 0u, len(v) - 1u).to_vec() } /// Returns the last element of the slice `v`, failing if the slice is empty. -pub pure fn last<T: Copy>(v: &[const T]) -> T { +pub pure fn last<T:Copy>(v: &[const T]) -> T { if len(v) == 0u { fail!(~"last_unsafe: empty vector") } v[len(v) - 1u] } @@ -247,7 +247,7 @@ pub pure fn last<T: Copy>(v: &[const T]) -> T { * Returns `Some(x)` where `x` is the last element of the slice `v`, * or `none` if the vector is empty. */ -pub pure fn last_opt<T: Copy>(v: &[const T]) -> Option<T> { +pub pure fn last_opt<T:Copy>(v: &[const T]) -> Option<T> { if len(v) == 0u { return None; } Some(v[len(v) - 1u]) } @@ -300,7 +300,7 @@ pub pure fn const_slice<T>(v: &r/[const T], start: uint, /// Copies /// Split the vector `v` by applying each element against the predicate `f`. -pub fn split<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn split<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -323,7 +323,7 @@ pub fn split<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { * Split the vector `v` by applying each element against the predicate `f` up * to `n` times. */ -pub fn splitn<T: Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn splitn<T:Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -349,7 +349,7 @@ pub fn splitn<T: Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { * Reverse split the vector `v` by applying each element against the predicate * `f`. */ -pub fn rsplit<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn rsplit<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0) { return ~[] } @@ -373,7 +373,7 @@ pub fn rsplit<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { * Reverse split the vector `v` by applying each element against the predicate * `f` up to `n times. */ -pub fn rsplitn<T: Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn rsplitn<T:Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -421,7 +421,7 @@ pub fn partition<T>(v: ~[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { * Partitions a vector into two new vectors: those that satisfies the * predicate, and those that do not. */ -pub pure fn partitioned<T: Copy>(v: &[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { +pub pure fn partitioned<T:Copy>(v: &[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { let mut lefts = ~[]; let mut rights = ~[]; @@ -616,7 +616,7 @@ fn push_slow<T>(v: &mut ~[T], initval: T) { } #[inline(always)] -pub fn push_all<T: Copy>(v: &mut ~[T], rhs: &[const T]) { +pub fn push_all<T:Copy>(v: &mut ~[T], rhs: &[const T]) { let new_len = v.len() + rhs.len(); reserve(&mut *v, new_len); @@ -662,7 +662,7 @@ pub fn truncate<T>(v: &mut ~[T], newlen: uint) { * Remove consecutive repeated elements from a vector; if the vector is * sorted, this removes all duplicates. */ -pub fn dedup<T: Eq>(v: &mut ~[T]) { +pub fn dedup<T:Eq>(v: &mut ~[T]) { unsafe { if v.len() < 1 { return; } let mut last_written = 0, next_to_read = 1; @@ -700,7 +700,7 @@ pub fn dedup<T: Eq>(v: &mut ~[T]) { // Appending #[inline(always)] -pub pure fn append<T: Copy>(lhs: ~[T], rhs: &[const T]) -> ~[T] { +pub pure fn append<T:Copy>(lhs: ~[T], rhs: &[const T]) -> ~[T] { let mut v = lhs; unsafe { v.push_all(rhs); @@ -724,7 +724,7 @@ pub pure fn append_one<T>(lhs: ~[T], x: T) -> ~[T] { * * n - The number of elements to add * * initval - The value for the new elements */ -pub fn grow<T: Copy>(v: &mut ~[T], n: uint, initval: &T) { +pub fn grow<T:Copy>(v: &mut ~[T], n: uint, initval: &T) { let new_len = v.len() + n; reserve_at_least(&mut *v, new_len); let mut i: uint = 0u; @@ -766,7 +766,7 @@ pub fn grow_fn<T>(v: &mut ~[T], n: uint, op: iter::InitOp<T>) { * of the vector, expands the vector by replicating `initval` to fill the * intervening space. */ -pub fn grow_set<T: Copy>(v: &mut ~[T], index: uint, initval: &T, val: T) { +pub fn grow_set<T:Copy>(v: &mut ~[T], index: uint, initval: &T, val: T) { let l = v.len(); if index >= l { grow(&mut *v, index - l + 1u, initval); } v[index] = val; @@ -813,7 +813,7 @@ pub pure fn flat_map<T, U>(v: &[T], f: fn(t: &T) -> ~[U]) -> ~[U] { } /// Apply a function to each pair of elements and return the results -pub pure fn map2<T: Copy, U: Copy, V>(v0: &[T], v1: &[U], +pub pure fn map2<T:Copy,U:Copy,V>(v0: &[T], v1: &[U], f: fn(t: &T, v: &U) -> V) -> ~[V] { let v0_len = len(v0); if v0_len != len(v1) { fail!(); } @@ -891,7 +891,7 @@ pub fn filter<T>(v: ~[T], f: fn(t: &T) -> bool) -> ~[T] { * Apply function `f` to each element of `v` and return a vector containing * only those elements for which `f` returned true. */ -pub pure fn filtered<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[T] { +pub pure fn filtered<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[T] { let mut result = ~[]; for each(v) |elem| { if f(elem) { unsafe { result.push(*elem); } } @@ -924,14 +924,14 @@ pub fn retain<T>(v: &mut ~[T], f: pure fn(t: &T) -> bool) { * * Flattens a vector of vectors of T into a single vector of T. */ -pub pure fn concat<T: Copy>(v: &[~[T]]) -> ~[T] { +pub pure fn concat<T:Copy>(v: &[~[T]]) -> ~[T] { let mut r = ~[]; for each(v) |inner| { unsafe { r.push_all(*inner); } } r } /// Concatenate a vector of vectors, placing a given separator between each -pub pure fn connect<T: Copy>(v: &[~[T]], sep: &T) -> ~[T] { +pub pure fn connect<T:Copy>(v: &[~[T]], sep: &T) -> ~[T] { let mut r: ~[T] = ~[]; let mut first = true; for each(v) |inner| { @@ -1060,13 +1060,13 @@ pub pure fn all2<T, U>(v0: &[T], v1: &[U], } /// Return true if a vector contains an element with the given value -pub pure fn contains<T: Eq>(v: &[T], x: &T) -> bool { +pub pure fn contains<T:Eq>(v: &[T], x: &T) -> bool { for each(v) |elt| { if *x == *elt { return true; } } return false; } /// Returns the number of elements that are equal to a given value -pub pure fn count<T: Eq>(v: &[T], x: &T) -> uint { +pub pure fn count<T:Eq>(v: &[T], x: &T) -> uint { let mut cnt = 0u; for each(v) |elt| { if *x == *elt { cnt += 1u; } } return cnt; @@ -1079,7 +1079,7 @@ pub pure fn count<T: Eq>(v: &[T], x: &T) -> uint { * 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>(v: &[T], f: fn(t: &T) -> bool) -> Option<T> { +pub pure fn find<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> Option<T> { find_between(v, 0u, len(v), f) } @@ -1090,7 +1090,7 @@ pub pure fn find<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> Option<T> { * [`start`, `end`). 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_between<T: Copy>(v: &[T], start: uint, end: uint, +pub pure fn find_between<T:Copy>(v: &[T], start: uint, end: uint, f: fn(t: &T) -> bool) -> Option<T> { position_between(v, start, end, f).map(|i| v[*i]) } @@ -1102,7 +1102,7 @@ pub pure fn find_between<T: Copy>(v: &[T], start: uint, end: uint, * `f` returns true then an option containing the element is returned. If `f` * matches no elements then none is returned. */ -pub pure fn rfind<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> Option<T> { +pub pure fn rfind<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> Option<T> { rfind_between(v, 0u, len(v), f) } @@ -1113,13 +1113,13 @@ pub pure fn rfind<T: Copy>(v: &[T], f: fn(t: &T) -> bool) -> Option<T> { * [`start`, `end`). When function `f` returns true then an option containing * the element is returned. If `f` matches no elements then none is return. */ -pub pure fn rfind_between<T: Copy>(v: &[T], start: uint, end: uint, +pub pure fn rfind_between<T:Copy>(v: &[T], start: uint, end: uint, f: fn(t: &T) -> bool) -> Option<T> { rposition_between(v, start, end, f).map(|i| v[*i]) } /// Find the first index containing a matching value -pub pure fn position_elem<T: Eq>(v: &[T], x: &T) -> Option<uint> { +pub pure fn position_elem<T:Eq>(v: &[T], x: &T) -> Option<uint> { position(v, |y| *x == *y) } @@ -1151,7 +1151,7 @@ pub pure fn position_between<T>(v: &[T], start: uint, end: uint, } /// Find the last index containing a matching value -pure fn rposition_elem<T: Eq>(v: &[T], x: &T) -> Option<uint> { +pure fn rposition_elem<T:Eq>(v: &[T], x: &T) -> Option<uint> { rposition(v, |y| *x == *y) } @@ -1193,7 +1193,7 @@ pub pure fn rposition_between<T>(v: &[T], start: uint, end: uint, /** * Convert a vector of pairs into a pair of vectors, by reference. As unzip(). */ -pure fn unzip_slice<T: Copy, U: Copy>(v: &[(T, U)]) -> (~[T], ~[U]) { +pure fn unzip_slice<T:Copy,U:Copy>(v: &[(T, U)]) -> (~[T], ~[U]) { let mut ts = ~[], us = ~[]; for each(v) |p| { let (t, u) = *p; @@ -1228,7 +1228,7 @@ pub pure fn unzip<T,U>(v: ~[(T, U)]) -> (~[T], ~[U]) { /** * Convert two vectors to a vector of pairs, by reference. As zip(). */ -pub pure fn zip_slice<T: Copy, U: Copy>(v: &[const T], u: &[const U]) +pub pure fn zip_slice<T:Copy,U:Copy>(v: &[const T], u: &[const U]) -> ~[(T, U)] { let mut zipped = ~[]; let sz = len(v); @@ -1279,7 +1279,7 @@ pub fn reverse<T>(v: &mut [T]) { } /// Returns a vector with the order of elements reversed -pub pure fn reversed<T: Copy>(v: &[const T]) -> ~[T] { +pub pure fn reversed<T:Copy>(v: &[const T]) -> ~[T] { let mut rs: ~[T] = ~[]; let mut i = len::<T>(v); if i == 0 { return (rs); } else { i -= 1; } @@ -1445,7 +1445,7 @@ pub fn each2<U, T>(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) { * The total number of permutations produced is `len(v)!`. If `v` contains * repeated elements, then some permutations are repeated. */ -pure fn each_permutation<T: Copy>(v: &[T], put: fn(ts: &[T]) -> bool) { +pure fn each_permutation<T:Copy>(v: &[T], put: fn(ts: &[T]) -> bool) { let ln = len(v); if ln <= 1 { put(v); @@ -1469,7 +1469,7 @@ pure fn each_permutation<T: Copy>(v: &[T], put: fn(ts: &[T]) -> bool) { } } -pub pure fn windowed<TT: Copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] { +pub pure fn windowed<TT:Copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] { let mut ww = ~[]; assert 1u <= nn; for vec::eachi (xx) |ii, _x| { @@ -1536,7 +1536,7 @@ pub pure fn as_mut_buf<T,U>(s: &mut [T], // Equality -pure fn eq<T: Eq>(a: &[T], b: &[T]) -> bool { +pure fn eq<T:Eq>(a: &[T], b: &[T]) -> bool { let (a_len, b_len) = (a.len(), b.len()); if a_len != b_len { return false; } @@ -1550,7 +1550,7 @@ pure fn eq<T: Eq>(a: &[T], b: &[T]) -> bool { } #[cfg(notest)] -impl<T: Eq> Eq for &[T] { +impl<T:Eq> Eq for &[T] { #[inline(always)] pure fn eq(&self, other: & &self/[T]) -> bool { eq((*self), (*other)) } #[inline(always)] @@ -1559,7 +1559,7 @@ impl<T: Eq> Eq for &[T] { #[cfg(notest)] -impl<T: Eq> Eq for ~[T] { +impl<T:Eq> Eq for ~[T] { #[inline(always)] pure fn eq(&self, other: &~[T]) -> bool { eq((*self), (*other)) } #[inline(always)] @@ -1567,7 +1567,7 @@ impl<T: Eq> Eq for ~[T] { } #[cfg(notest)] -impl<T: Eq> Eq for @[T] { +impl<T:Eq> Eq for @[T] { #[inline(always)] pure fn eq(&self, other: &@[T]) -> bool { eq((*self), (*other)) } #[inline(always)] @@ -1576,7 +1576,7 @@ impl<T: Eq> Eq for @[T] { // Lexicographical comparison -pure fn lt<T: Ord>(a: &[T], b: &[T]) -> bool { +pure fn lt<T:Ord>(a: &[T], b: &[T]) -> bool { let (a_len, b_len) = (a.len(), b.len()); let mut end = uint::min(a_len, b_len); @@ -1591,12 +1591,12 @@ pure fn lt<T: Ord>(a: &[T], b: &[T]) -> bool { return a_len < b_len; } -pure fn le<T: Ord>(a: &[T], b: &[T]) -> bool { !lt(b, a) } -pure fn ge<T: Ord>(a: &[T], b: &[T]) -> bool { !lt(a, b) } -pure fn gt<T: Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) } +pure fn le<T:Ord>(a: &[T], b: &[T]) -> bool { !lt(b, a) } +pure fn ge<T:Ord>(a: &[T], b: &[T]) -> bool { !lt(a, b) } +pure fn gt<T:Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) } #[cfg(notest)] -impl<T: Ord> Ord for &[T] { +impl<T:Ord> Ord for &[T] { #[inline(always)] pure fn lt(&self, other: & &self/[T]) -> bool { lt((*self), (*other)) } #[inline(always)] @@ -1608,7 +1608,7 @@ impl<T: Ord> Ord for &[T] { } #[cfg(notest)] -impl<T: Ord> Ord for ~[T] { +impl<T:Ord> Ord for ~[T] { #[inline(always)] pure fn lt(&self, other: &~[T]) -> bool { lt((*self), (*other)) } #[inline(always)] @@ -1620,7 +1620,7 @@ impl<T: Ord> Ord for ~[T] { } #[cfg(notest)] -impl<T: Ord> Ord for @[T] { +impl<T:Ord> Ord for @[T] { #[inline(always)] pure fn lt(&self, other: &@[T]) -> bool { lt((*self), (*other)) } #[inline(always)] @@ -1637,7 +1637,7 @@ pub mod traits { use ops::Add; use vec::append; - impl<T: Copy> Add<&[const T],~[T]> for ~[T] { + impl<T:Copy> Add<&[const T],~[T]> for ~[T] { #[inline(always)] pure fn add(&self, rhs: & &self/[const T]) -> ~[T] { append(copy *self, (*rhs)) @@ -1664,7 +1664,7 @@ pub trait CopyableVector<T> { } /// Extension methods for vectors -impl<T: Copy> CopyableVector<T> for &[const T] { +impl<T:Copy> CopyableVector<T> for &[const T] { /// Returns the first element of a vector #[inline] pure fn head(&self) -> T { head(*self) } @@ -1690,13 +1690,13 @@ impl<T: Copy> CopyableVector<T> for &[const T] { pub trait ImmutableVector<T> { pure fn view(&self, start: uint, end: uint) -> &self/[T]; - pure fn foldr<U: Copy>(&self, z: U, p: fn(t: &T, u: U) -> U) -> U; + pure fn foldr<U:Copy>(&self, z: U, p: fn(t: &T, u: U) -> U) -> U; pure fn map<U>(&self, f: fn(t: &T) -> U) -> ~[U]; pure fn mapi<U>(&self, f: fn(uint, t: &T) -> U) -> ~[U]; fn map_r<U>(&self, f: fn(x: &T) -> U) -> ~[U]; pure fn alli(&self, f: fn(uint, t: &T) -> bool) -> bool; pure fn flat_map<U>(&self, f: fn(t: &T) -> ~[U]) -> ~[U]; - pure fn filter_mapped<U: Copy>(&self, f: fn(t: &T) -> Option<U>) -> ~[U]; + pure fn filter_mapped<U:Copy>(&self, f: fn(t: &T) -> Option<U>) -> ~[U]; } /// Extension methods for vectors @@ -1709,7 +1709,7 @@ impl<T> ImmutableVector<T> for &[T] { /// Reduce a vector from right to left #[inline] - pure fn foldr<U: Copy>(&self, z: U, p: fn(t: &T, u: U) -> U) -> U { + pure fn foldr<U:Copy>(&self, z: U, p: fn(t: &T, u: U) -> U) -> U { foldr(*self, z, p) } @@ -1759,19 +1759,19 @@ impl<T> ImmutableVector<T> for &[T] { * the resulting vector. */ #[inline] - pure fn filter_mapped<U: Copy>(&self, f: fn(t: &T) -> Option<U>) -> ~[U] { + pure fn filter_mapped<U:Copy>(&self, f: fn(t: &T) -> Option<U>) -> ~[U] { filter_mapped(*self, f) } } -pub trait ImmutableEqVector<T: Eq> { +pub trait ImmutableEqVector<T:Eq> { pure fn position(&self, f: fn(t: &T) -> bool) -> Option<uint>; pure fn position_elem(&self, t: &T) -> Option<uint>; pure fn rposition(&self, f: fn(t: &T) -> bool) -> Option<uint>; pure fn rposition_elem(&self, t: &T) -> Option<uint>; } -impl<T: Eq> ImmutableEqVector<T> for &[T] { +impl<T:Eq> ImmutableEqVector<T> for &[T] { /** * Find the first index matching some predicate * @@ -1816,7 +1816,7 @@ pub trait ImmutableCopyableVector<T> { } /// Extension methods for vectors -impl<T: Copy> ImmutableCopyableVector<T> for &[T] { +impl<T:Copy> ImmutableCopyableVector<T> for &[T] { /** * Construct a new vector from the elements of a vector for which some * predicate holds. @@ -1949,13 +1949,13 @@ impl<T> Mutable for ~[T] { fn clear(&mut self) { self.truncate(0) } } -pub trait OwnedCopyableVector<T: Copy> { +pub trait OwnedCopyableVector<T:Copy> { fn push_all(&mut self, rhs: &[const T]); fn grow(&mut self, n: uint, initval: &T); fn grow_set(&mut self, index: uint, initval: &T, val: T); } -impl<T: Copy> OwnedCopyableVector<T> for ~[T] { +impl<T:Copy> OwnedCopyableVector<T> for ~[T] { #[inline] fn push_all(&mut self, rhs: &[const T]) { push_all(self, rhs); @@ -1972,11 +1972,11 @@ impl<T: Copy> OwnedCopyableVector<T> for ~[T] { } } -trait OwnedEqVector<T: Eq> { +trait OwnedEqVector<T:Eq> { fn dedup(&mut self); } -impl<T: Eq> OwnedEqVector<T> for ~[T] { +impl<T:Eq> OwnedEqVector<T> for ~[T] { #[inline] fn dedup(&mut self) { dedup(self) @@ -2086,7 +2086,7 @@ pub mod raw { * Unchecked vector indexing. */ #[inline(always)] - pub unsafe fn get<T: Copy>(v: &[const T], i: uint) -> T { + pub unsafe fn get<T:Copy>(v: &[const T], i: uint) -> T { as_const_buf(v, |p, _len| *ptr::const_offset(p, i)) } @@ -2324,24 +2324,24 @@ impl<A> iter::ExtendedIter<A> for @[A] { } } -impl<A: Eq> iter::EqIter<A> for &[A] { +impl<A:Eq> iter::EqIter<A> for &[A] { pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } } // FIXME(#4148): This should be redundant -impl<A: Eq> iter::EqIter<A> for ~[A] { +impl<A:Eq> iter::EqIter<A> for ~[A] { pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } } // FIXME(#4148): This should be redundant -impl<A: Eq> iter::EqIter<A> for @[A] { +impl<A:Eq> iter::EqIter<A> for @[A] { pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } } -impl<A: Copy> iter::CopyableIter<A> for &[A] { +impl<A:Copy> iter::CopyableIter<A> for &[A] { pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } @@ -2352,7 +2352,7 @@ impl<A: Copy> iter::CopyableIter<A> for &[A] { } // FIXME(#4148): This should be redundant -impl<A: Copy> iter::CopyableIter<A> for ~[A] { +impl<A:Copy> iter::CopyableIter<A> for ~[A] { pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } @@ -2363,7 +2363,7 @@ impl<A: Copy> iter::CopyableIter<A> for ~[A] { } // FIXME(#4148): This should be redundant -impl<A: Copy> iter::CopyableIter<A> for @[A] { +impl<A:Copy> iter::CopyableIter<A> for @[A] { pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } @@ -2373,19 +2373,19 @@ impl<A: Copy> iter::CopyableIter<A> for @[A] { } } -impl<A: Copy Ord> iter::CopyableOrderedIter<A> for &[A] { +impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for &[A] { pure fn min(&self) -> A { iter::min(self) } pure fn max(&self) -> A { iter::max(self) } } // FIXME(#4148): This should be redundant -impl<A: Copy Ord> iter::CopyableOrderedIter<A> for ~[A] { +impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for ~[A] { pure fn min(&self) -> A { iter::min(self) } pure fn max(&self) -> A { iter::max(self) } } // FIXME(#4148): This should be redundant -impl<A: Copy Ord> iter::CopyableOrderedIter<A> for @[A] { +impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for @[A] { pure fn min(&self) -> A { iter::min(self) } pure fn max(&self) -> A { iter::max(self) } } |
