Skip to content

librustc: Replace impl Type : Trait with impl Trait for Type. rs=imp... #4932

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

Merged
merged 1 commit into from
Feb 14, 2013
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion src/libcore/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn all_values(blk: fn(v: bool)) {
pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }

#[cfg(notest)]
impl bool : cmp::Eq {
impl cmp::Eq for bool {
pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ pub pure fn cmp(a: char, b: char) -> int {
}

#[cfg(notest)]
impl char : Eq {
impl Eq for char {
pure fn eq(&self, other: &char) -> bool { (*self) == (*other) }
pure fn ne(&self, other: &char) -> bool { (*self) != (*other) }
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait Clone {
fn clone(&self) -> Self;
}

impl (): Clone {
impl Clone for () {
#[inline(always)]
fn clone(&self) -> () { () }
}
2 changes: 1 addition & 1 deletion src/libcore/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ struct Guard<T, U> {
cond: &Condition<T, U>
}

impl<T, U> Guard<T, U> : Drop {
impl<T, U> Drop for Guard<T, U> {
fn finalize(&self) {
unsafe {
debug!("Guard: popping handler from TLS");
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/dvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl<A: Copy> DVec<A> {
}
}

impl<A:Copy> DVec<A>: Index<uint,A> {
impl<A:Copy> Index<uint,A> for DVec<A> {
#[inline(always)]
pure fn index(&self, idx: uint) -> A {
self.get_elt(idx)
Expand Down
8 changes: 4 additions & 4 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> A: HashUtil {
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> A: Hash {
impl<A: IterBytes> Hash for A {
#[inline(always)]
pure fn hash_keyed(k0: u64, k1: u64) -> u64 {
unsafe {
Expand Down Expand Up @@ -187,7 +187,7 @@ fn SipState(key0: u64, key1: u64) -> SipState {
}


impl SipState : io::Writer {
impl io::Writer for SipState {

// Methods for io::writer
#[inline(always)]
Expand Down Expand Up @@ -295,7 +295,7 @@ impl SipState : io::Writer {
}
}

impl &SipState : Streaming {
impl Streaming for &SipState {

#[inline(always)]
fn input(buf: &[const u8]) {
Expand Down
20 changes: 10 additions & 10 deletions src/libcore/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ pub mod linear {
}
}

impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: BaseIter<(&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 @@ -257,15 +257,15 @@ pub mod linear {
}


impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: Container {
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> LinearMap<K, V>: Mutable {
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 @@ -275,7 +275,7 @@ pub mod linear {
}
}

impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: Map<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 @@ -443,7 +443,7 @@ pub mod linear {
}
}

impl<K: Hash IterBytes Eq, V: Eq> LinearMap<K, V>: Eq {
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 @@ -464,13 +464,13 @@ pub mod linear {
priv map: LinearMap<T, ()>
}

impl <T: Hash IterBytes Eq> LinearSet<T>: BaseIter<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> LinearSet<T>: Eq {
impl<T: Hash IterBytes Eq> Eq for LinearSet<T> {
pure fn eq(&self, other: &LinearSet<T>) -> bool {
self.map == other.map
}
Expand All @@ -479,20 +479,20 @@ pub mod linear {
}
}

impl <T: Hash IterBytes Eq> LinearSet<T>: Container {
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> LinearSet<T>: Mutable {
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> LinearSet<T>: Set<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
20 changes: 10 additions & 10 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> T : ReaderUtil {
impl<T: Reader> ReaderUtil for T {

fn read_bytes(&self,len: uint) -> ~[u8] {
let mut bytes = vec::with_capacity(len);
Expand Down Expand Up @@ -415,7 +415,7 @@ fn convert_whence(whence: SeekStyle) -> i32 {
};
}

impl *libc::FILE: Reader {
impl Reader for *libc::FILE {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
unsafe {
do vec::as_mut_buf(bytes) |buf_p, buf_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> Wrapper<R, C>: Reader {
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 @@ -527,7 +527,7 @@ pub struct BytesReader {
mut pos: uint
}

impl BytesReader: Reader {
impl Reader for BytesReader {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
let count = uint::min(len, self.bytes.len() - self.pos);

Expand Down Expand Up @@ -589,15 +589,15 @@ pub trait Writer {
fn get_type(&self) -> WriterType;
}

impl<W: Writer, C> Wrapper<W, C>: Writer {
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() }
fn flush(&self) -> int { self.base.flush() }
fn get_type(&self) -> WriterType { File }
}

impl *libc::FILE: Writer {
impl Writer for *libc::FILE {
fn write(&self, v: &[const u8]) {
unsafe {
do vec::as_const_buf(v) |vbuf, len| {
Expand Down Expand Up @@ -647,7 +647,7 @@ pub fn FILE_writer(f: *libc::FILE, cleanup: bool) -> Writer {
}
}

impl fd_t: Writer {
impl Writer for fd_t {
fn write(&self, v: &[const u8]) {
unsafe {
let mut count = 0u;
Expand Down Expand Up @@ -890,7 +890,7 @@ pub trait WriterUtil {
fn write_i8(&self, n: i8);
}

impl<T: Writer> T : WriterUtil {
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 @@ -996,7 +996,7 @@ pub struct BytesWriter {
mut pos: uint,
}

impl BytesWriter: Writer {
impl Writer for BytesWriter {
fn write(&self, v: &[const u8]) {
do self.bytes.swap |bytes| {
let mut bytes = move bytes;
Expand Down Expand Up @@ -1112,7 +1112,7 @@ pub mod fsync {
arg: Arg<t>,
}

impl<T: Copy> Res<T>: Drop {
impl<T: Copy> Drop for Res<T> {
fn finalize(&self) {
match self.arg.opt_level {
None => (),
Expand Down
10 changes: 5 additions & 5 deletions src/libcore/iter-trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ use option::Option;

use self::inst::{IMPL_T, EACH, SIZE_HINT};

impl<A> IMPL_T<A>: iter::BaseIter<A> {
impl<A> iter::BaseIter<A> for IMPL_T<A> {
#[inline(always)]
pure fn each(&self, blk: fn(v: &A) -> bool) { EACH(self, blk) }
#[inline(always)]
pure fn size_hint(&self) -> Option<uint> { SIZE_HINT(self) }
}

impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
impl<A> iter::ExtendedIter<A> for IMPL_T<A> {
#[inline(always)]
pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
iter::eachi(self, blk)
Expand Down Expand Up @@ -60,14 +60,14 @@ impl<A> IMPL_T<A>: iter::ExtendedIter<A> {

}

impl<A: Eq> IMPL_T<A>: iter::EqIter<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> IMPL_T<A>: iter::CopyableIter<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> IMPL_T<A>: iter::CopyableIter<A> {
}
}

impl<A: Copy Ord> IMPL_T<A>: iter::CopyableOrderedIter<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
4 changes: 2 additions & 2 deletions src/libcore/managed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ pub pure fn mut_ptr_eq<T>(a: @mut T, b: @mut T) -> bool {
}

#[cfg(notest)]
impl<T:Eq> @const T : Eq {
impl<T:Eq> Eq for @const T {
#[inline(always)]
pure fn eq(&self, other: &@const T) -> bool { *(*self) == *(*other) }
#[inline(always)]
pure fn ne(&self, other: &@const T) -> bool { *(*self) != *(*other) }
}

#[cfg(notest)]
impl<T:Ord> @const T : Ord {
impl<T:Ord> Ord for @const T {
#[inline(always)]
pure fn lt(&self, other: &@const T) -> bool { *(*self) < *(*other) }
#[inline(always)]
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/nil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Functions for the unit type.
use cmp::{Eq, Ord};

#[cfg(notest)]
impl () : Eq {
impl Eq for () {
#[inline(always)]
pure fn eq(&self, _other: &()) -> bool { true }
#[inline(always)]
pure fn ne(&self, _other: &()) -> bool { false }
}

#[cfg(notest)]
impl () : Ord {
impl Ord for () {
#[inline(always)]
pure fn lt(&self, _other: &()) -> bool { false }
#[inline(always)]
Expand Down
Loading