Skip to content

librustc: Separate most trait bounds with '+'. rs=plussing #5063

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/libcore/at_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]); }
Expand Down Expand Up @@ -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; }
Expand Down Expand Up @@ -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))
Expand Down
16 changes: 8 additions & 8 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
4 changes: 2 additions & 2 deletions src/libcore/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/dvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
Expand All @@ -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 {
Expand Down
30 changes: 15 additions & 15 deletions src/libcore/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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| {
Expand All @@ -263,15 +263,15 @@ 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 }

/// Return true if the map contains no elements
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| {
Expand All @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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; }

Expand All @@ -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
}
Expand All @@ -493,20 +493,20 @@ 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() }

/// Return true if the set contains no elements
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)
Expand Down Expand Up @@ -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()} }

Expand Down
12 changes: 6 additions & 6 deletions src/libcore/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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() }
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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 => (),
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/iter-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)]
Expand Down
Loading