librustc: Replace impl Type : Trait with impl Trait for Type. rs=implflipping

This commit is contained in:
Patrick Walton 2013-02-14 11:47:00 -08:00
parent 8ec6f43d6c
commit 9143688197
583 changed files with 1115 additions and 1115 deletions

View file

@ -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 } } pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
#[cfg(notest)] #[cfg(notest)]
impl bool : cmp::Eq { impl cmp::Eq for bool {
pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) } pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) } pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
} }

View file

@ -251,7 +251,7 @@ pub pure fn cmp(a: char, b: char) -> int {
} }
#[cfg(notest)] #[cfg(notest)]
impl char : Eq { impl Eq for char {
pure fn eq(&self, other: &char) -> bool { (*self) == (*other) } pure fn eq(&self, other: &char) -> bool { (*self) == (*other) }
pure fn ne(&self, other: &char) -> bool { (*self) != (*other) } pure fn ne(&self, other: &char) -> bool { (*self) != (*other) }
} }

View file

@ -15,7 +15,7 @@ pub trait Clone {
fn clone(&self) -> Self; fn clone(&self) -> Self;
} }
impl (): Clone { impl Clone for () {
#[inline(always)] #[inline(always)]
fn clone(&self) -> () { () } fn clone(&self) -> () { () }
} }

View file

@ -84,7 +84,7 @@ struct Guard<T, U> {
cond: &Condition<T, U> cond: &Condition<T, U>
} }
impl<T, U> Guard<T, U> : Drop { impl<T, U> Drop for Guard<T, U> {
fn finalize(&self) { fn finalize(&self) {
unsafe { unsafe {
debug!("Guard: popping handler from TLS"); debug!("Guard: popping handler from TLS");

View file

@ -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)] #[inline(always)]
pure fn index(&self, idx: uint) -> A { pure fn index(&self, idx: uint) -> A {
self.get_elt(idx) self.get_elt(idx)

View file

@ -59,7 +59,7 @@ pub trait HashUtil {
pure fn hash() -> u64; pure fn hash() -> u64;
} }
impl <A: Hash> A: HashUtil { impl<A: Hash> HashUtil for A {
#[inline(always)] #[inline(always)]
pure fn hash() -> u64 { self.hash_keyed(0,0) } pure fn hash() -> u64 { self.hash_keyed(0,0) }
} }
@ -74,7 +74,7 @@ pub trait Streaming {
fn reset(); fn reset();
} }
impl <A: IterBytes> A: Hash { impl<A: IterBytes> Hash for A {
#[inline(always)] #[inline(always)]
pure fn hash_keyed(k0: u64, k1: u64) -> u64 { pure fn hash_keyed(k0: u64, k1: u64) -> u64 {
unsafe { unsafe {
@ -187,7 +187,7 @@ fn SipState(key0: u64, key1: u64) -> SipState {
} }
impl SipState : io::Writer { impl io::Writer for SipState {
// Methods for io::writer // Methods for io::writer
#[inline(always)] #[inline(always)]
@ -295,7 +295,7 @@ impl SipState : io::Writer {
} }
} }
impl &SipState : Streaming { impl Streaming for &SipState {
#[inline(always)] #[inline(always)]
fn input(buf: &[const u8]) { fn input(buf: &[const u8]) {

View file

@ -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 /// Visit all key-value pairs
pure fn each(&self, blk: fn(&(&self/K, &self/V)) -> bool) { pure fn each(&self, blk: fn(&(&self/K, &self/V)) -> bool) {
for uint::range(0, self.buckets.len()) |i| { for uint::range(0, self.buckets.len()) |i| {
@ -257,7 +257,7 @@ 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 /// Return the number of elements in the map
pure fn len(&self) -> uint { self.size } pure fn len(&self) -> uint { self.size }
@ -265,7 +265,7 @@ pub mod linear {
pure fn is_empty(&self) -> bool { self.len() == 0 } 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. /// Clear the map, removing all key-value pairs.
fn clear(&mut self) { fn clear(&mut self) {
for uint::range(0, self.buckets.len()) |idx| { for uint::range(0, self.buckets.len()) |idx| {
@ -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 /// Return true if the map contains a value for the specified key
pure fn contains_key(&self, k: &K) -> bool { pure fn contains_key(&self, k: &K) -> bool {
match self.bucket_for_key(k) { match self.bucket_for_key(k) {
@ -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 { pure fn eq(&self, other: &LinearMap<K, V>) -> bool {
if self.len() != other.len() { return false; } if self.len() != other.len() { return false; }
@ -464,13 +464,13 @@ pub mod linear {
priv map: LinearMap<T, ()> 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 /// Visit all values in order
pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) } pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) }
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } 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 { pure fn eq(&self, other: &LinearSet<T>) -> bool {
self.map == other.map self.map == other.map
} }
@ -479,7 +479,7 @@ 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 /// Return the number of elements in the set
pure fn len(&self) -> uint { self.map.len() } pure fn len(&self) -> uint { self.map.len() }
@ -487,12 +487,12 @@ pub mod linear {
pure fn is_empty(&self) -> bool { self.map.is_empty() } 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. /// Clear the set, removing all values.
fn clear(&mut self) { self.map.clear() } 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 /// Return true if the set contains a value
pure fn contains(&self, value: &T) -> bool { pure fn contains(&self, value: &T) -> bool {
self.map.contains_key(value) self.map.contains_key(value)

View file

@ -169,7 +169,7 @@ pub trait ReaderUtil {
fn read_i8(&self) -> i8; fn read_i8(&self) -> i8;
} }
impl<T: Reader> T : ReaderUtil { impl<T: Reader> ReaderUtil for T {
fn read_bytes(&self,len: uint) -> ~[u8] { fn read_bytes(&self,len: uint) -> ~[u8] {
let mut bytes = vec::with_capacity(len); let mut bytes = vec::with_capacity(len);
@ -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 { fn read(&self, bytes: &mut [u8], len: uint) -> uint {
unsafe { unsafe {
do vec::as_mut_buf(bytes) |buf_p, buf_len| { do vec::as_mut_buf(bytes) |buf_p, buf_len| {
@ -460,7 +460,7 @@ struct Wrapper<T, C> {
// A forwarding impl of reader that also holds on to a resource for the // A forwarding impl of reader that also holds on to a resource for the
// duration of its lifetime. // duration of its lifetime.
// FIXME there really should be a better way to do this // #2004 // 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 { fn read(&self, bytes: &mut [u8], len: uint) -> uint {
self.base.read(bytes, len) self.base.read(bytes, len)
} }
@ -527,7 +527,7 @@ pub struct BytesReader {
mut pos: uint mut pos: uint
} }
impl BytesReader: Reader { impl Reader for BytesReader {
fn read(&self, bytes: &mut [u8], len: uint) -> uint { fn read(&self, bytes: &mut [u8], len: uint) -> uint {
let count = uint::min(len, self.bytes.len() - self.pos); let count = uint::min(len, self.bytes.len() - self.pos);
@ -589,7 +589,7 @@ pub trait Writer {
fn get_type(&self) -> WriterType; 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 write(&self, bs: &[const u8]) { self.base.write(bs); }
fn seek(&self, off: int, style: SeekStyle) { self.base.seek(off, style); } fn seek(&self, off: int, style: SeekStyle) { self.base.seek(off, style); }
fn tell(&self) -> uint { self.base.tell() } fn tell(&self) -> uint { self.base.tell() }
@ -597,7 +597,7 @@ impl<W: Writer, C> Wrapper<W, C>: Writer {
fn get_type(&self) -> WriterType { File } fn get_type(&self) -> WriterType { File }
} }
impl *libc::FILE: Writer { impl Writer for *libc::FILE {
fn write(&self, v: &[const u8]) { fn write(&self, v: &[const u8]) {
unsafe { unsafe {
do vec::as_const_buf(v) |vbuf, len| { do vec::as_const_buf(v) |vbuf, len| {
@ -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]) { fn write(&self, v: &[const u8]) {
unsafe { unsafe {
let mut count = 0u; let mut count = 0u;
@ -890,7 +890,7 @@ pub trait WriterUtil {
fn write_i8(&self, n: i8); fn write_i8(&self, n: i8);
} }
impl<T: Writer> T : WriterUtil { impl<T: Writer> WriterUtil for T {
fn write_char(&self, ch: char) { fn write_char(&self, ch: char) {
if ch as uint < 128u { if ch as uint < 128u {
self.write(&[ch as u8]); self.write(&[ch as u8]);
@ -996,7 +996,7 @@ pub struct BytesWriter {
mut pos: uint, mut pos: uint,
} }
impl BytesWriter: Writer { impl Writer for BytesWriter {
fn write(&self, v: &[const u8]) { fn write(&self, v: &[const u8]) {
do self.bytes.swap |bytes| { do self.bytes.swap |bytes| {
let mut bytes = move bytes; let mut bytes = move bytes;
@ -1112,7 +1112,7 @@ pub mod fsync {
arg: Arg<t>, arg: Arg<t>,
} }
impl<T: Copy> Res<T>: Drop { impl<T: Copy> Drop for Res<T> {
fn finalize(&self) { fn finalize(&self) {
match self.arg.opt_level { match self.arg.opt_level {
None => (), None => (),

View file

@ -20,14 +20,14 @@ use option::Option;
use self::inst::{IMPL_T, EACH, SIZE_HINT}; 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)] #[inline(always)]
pure fn each(&self, blk: fn(v: &A) -> bool) { EACH(self, blk) } pure fn each(&self, blk: fn(v: &A) -> bool) { EACH(self, blk) }
#[inline(always)] #[inline(always)]
pure fn size_hint(&self) -> Option<uint> { SIZE_HINT(self) } 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)] #[inline(always)]
pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
iter::eachi(self, blk) iter::eachi(self, blk)
@ -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)] #[inline(always)]
pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
#[inline(always)] #[inline(always)]
pure fn count(&self, x: &A) -> uint { iter::count(self, x) } 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)] #[inline(always)]
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred) iter::filter_to_vec(self, pred)
@ -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)] #[inline(always)]
pure fn min(&self) -> A { iter::min(self) } pure fn min(&self) -> A { iter::min(self) }
#[inline(always)] #[inline(always)]

View file

@ -46,7 +46,7 @@ pub pure fn mut_ptr_eq<T>(a: @mut T, b: @mut T) -> bool {
} }
#[cfg(notest)] #[cfg(notest)]
impl<T:Eq> @const T : Eq { impl<T:Eq> Eq for @const T {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &@const T) -> bool { *(*self) == *(*other) } pure fn eq(&self, other: &@const T) -> bool { *(*self) == *(*other) }
#[inline(always)] #[inline(always)]
@ -54,7 +54,7 @@ impl<T:Eq> @const T : Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl<T:Ord> @const T : Ord { impl<T:Ord> Ord for @const T {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &@const T) -> bool { *(*self) < *(*other) } pure fn lt(&self, other: &@const T) -> bool { *(*self) < *(*other) }
#[inline(always)] #[inline(always)]

View file

@ -17,7 +17,7 @@ Functions for the unit type.
use cmp::{Eq, Ord}; use cmp::{Eq, Ord};
#[cfg(notest)] #[cfg(notest)]
impl () : Eq { impl Eq for () {
#[inline(always)] #[inline(always)]
pure fn eq(&self, _other: &()) -> bool { true } pure fn eq(&self, _other: &()) -> bool { true }
#[inline(always)] #[inline(always)]
@ -25,7 +25,7 @@ impl () : Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl () : Ord { impl Ord for () {
#[inline(always)] #[inline(always)]
pure fn lt(&self, _other: &()) -> bool { false } pure fn lt(&self, _other: &()) -> bool { false }
#[inline(always)] #[inline(always)]

View file

@ -253,7 +253,7 @@ pub pure fn logarithm(n: f32, b: f32) -> f32 {
} }
#[cfg(notest)] #[cfg(notest)]
impl f32 : cmp::Eq { impl cmp::Eq for f32 {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &f32) -> bool { (*self) == (*other) } pure fn eq(&self, other: &f32) -> bool { (*self) == (*other) }
#[inline(always)] #[inline(always)]
@ -261,7 +261,7 @@ impl f32 : cmp::Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl f32 : cmp::Ord { impl cmp::Ord for f32 {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &f32) -> bool { (*self) < (*other) } pure fn lt(&self, other: &f32) -> bool { (*self) < (*other) }
#[inline(always)] #[inline(always)]
@ -272,12 +272,12 @@ impl f32 : cmp::Ord {
pure fn gt(&self, other: &f32) -> bool { (*self) > (*other) } pure fn gt(&self, other: &f32) -> bool { (*self) > (*other) }
} }
impl f32: num::Zero { impl num::Zero for f32 {
#[inline(always)] #[inline(always)]
static pure fn zero() -> f32 { 0.0 } static pure fn zero() -> f32 { 0.0 }
} }
impl f32: num::One { impl num::One for f32 {
#[inline(always)] #[inline(always)]
static pure fn one() -> f32 { 1.0 } static pure fn one() -> f32 { 1.0 }
} }
@ -336,7 +336,7 @@ pub extern {
fn floorf32(val: f32) -> f32; fn floorf32(val: f32) -> f32;
} }
impl f32: num::Round { impl num::Round for f32 {
#[inline(always)] #[inline(always)]
pure fn round(&self, mode: num::RoundMode) -> f32 { pure fn round(&self, mode: num::RoundMode) -> f32 {
match mode { match mode {
@ -464,12 +464,12 @@ pub pure fn to_str_digits(num: f32, dig: uint) -> ~str {
r r
} }
impl f32: to_str::ToStr { impl to_str::ToStr for f32 {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) } pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
} }
impl f32: num::ToStrRadix { impl num::ToStrRadix for f32 {
#[inline(always)] #[inline(always)]
pure fn to_str_radix(&self, rdx: uint) -> ~str { pure fn to_str_radix(&self, rdx: uint) -> ~str {
to_str_radix(*self, rdx) to_str_radix(*self, rdx)
@ -564,12 +564,12 @@ pub pure fn from_str_radix(num: &str, rdx: uint) -> Option<f32> {
num::from_str_common(num, rdx, true, true, false, num::ExpNone, false) num::from_str_common(num, rdx, true, true, false, num::ExpNone, false)
} }
impl f32: from_str::FromStr { impl from_str::FromStr for f32 {
#[inline(always)] #[inline(always)]
static pure fn from_str(val: &str) -> Option<f32> { from_str(val) } static pure fn from_str(val: &str) -> Option<f32> { from_str(val) }
} }
impl f32: num::FromStrRadix { impl num::FromStrRadix for f32 {
#[inline(always)] #[inline(always)]
static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f32> { static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f32> {
from_str_radix(val, rdx) from_str_radix(val, rdx)

View file

@ -278,7 +278,7 @@ pub pure fn logarithm(n: f64, b: f64) -> f64 {
} }
#[cfg(notest)] #[cfg(notest)]
impl f64 : cmp::Eq { impl cmp::Eq for f64 {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &f64) -> bool { (*self) == (*other) } pure fn eq(&self, other: &f64) -> bool { (*self) == (*other) }
#[inline(always)] #[inline(always)]
@ -286,7 +286,7 @@ impl f64 : cmp::Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl f64 : cmp::Ord { impl cmp::Ord for f64 {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &f64) -> bool { (*self) < (*other) } pure fn lt(&self, other: &f64) -> bool { (*self) < (*other) }
#[inline(always)] #[inline(always)]
@ -321,12 +321,12 @@ pub impl f64: NumCast {
#[inline(always)] pure fn to_float(&self) -> float { *self as float } #[inline(always)] pure fn to_float(&self) -> float { *self as float }
} }
impl f64: num::Zero { impl num::Zero for f64 {
#[inline(always)] #[inline(always)]
static pure fn zero() -> f64 { 0.0 } static pure fn zero() -> f64 { 0.0 }
} }
impl f64: num::One { impl num::One for f64 {
#[inline(always)] #[inline(always)]
static pure fn one() -> f64 { 1.0 } static pure fn one() -> f64 { 1.0 }
} }
@ -361,7 +361,7 @@ pub extern {
fn floorf64(val: f64) -> f64; fn floorf64(val: f64) -> f64;
} }
impl f64: num::Round { impl num::Round for f64 {
#[inline(always)] #[inline(always)]
pure fn round(&self, mode: num::RoundMode) -> f64 { pure fn round(&self, mode: num::RoundMode) -> f64 {
match mode { match mode {
@ -489,12 +489,12 @@ pub pure fn to_str_digits(num: f64, dig: uint) -> ~str {
r r
} }
impl f64: to_str::ToStr { impl to_str::ToStr for f64 {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) } pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
} }
impl f64: num::ToStrRadix { impl num::ToStrRadix for f64 {
#[inline(always)] #[inline(always)]
pure fn to_str_radix(&self, rdx: uint) -> ~str { pure fn to_str_radix(&self, rdx: uint) -> ~str {
to_str_radix(*self, rdx) to_str_radix(*self, rdx)
@ -589,12 +589,12 @@ pub pure fn from_str_radix(num: &str, rdx: uint) -> Option<f64> {
num::from_str_common(num, rdx, true, true, false, num::ExpNone, false) num::from_str_common(num, rdx, true, true, false, num::ExpNone, false)
} }
impl f64: from_str::FromStr { impl from_str::FromStr for f64 {
#[inline(always)] #[inline(always)]
static pure fn from_str(val: &str) -> Option<f64> { from_str(val) } static pure fn from_str(val: &str) -> Option<f64> { from_str(val) }
} }
impl f64: num::FromStrRadix { impl num::FromStrRadix for f64 {
#[inline(always)] #[inline(always)]
static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f64> { static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f64> {
from_str_radix(val, rdx) from_str_radix(val, rdx)

View file

@ -201,12 +201,12 @@ pub pure fn to_str_digits(num: float, digits: uint) -> ~str {
r r
} }
impl float: to_str::ToStr { impl to_str::ToStr for float {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) } pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
} }
impl float: num::ToStrRadix { impl num::ToStrRadix for float {
#[inline(always)] #[inline(always)]
pure fn to_str_radix(&self, radix: uint) -> ~str { pure fn to_str_radix(&self, radix: uint) -> ~str {
to_str_radix(*self, radix) to_str_radix(*self, radix)
@ -301,12 +301,12 @@ pub pure fn from_str_radix(num: &str, radix: uint) -> Option<float> {
num::from_str_common(num, radix, true, true, false, num::ExpNone, false) num::from_str_common(num, radix, true, true, false, num::ExpNone, false)
} }
impl float: from_str::FromStr { impl from_str::FromStr for float {
#[inline(always)] #[inline(always)]
static pure fn from_str(val: &str) -> Option<float> { from_str(val) } static pure fn from_str(val: &str) -> Option<float> { from_str(val) }
} }
impl float: num::FromStrRadix { impl num::FromStrRadix for float {
#[inline(always)] #[inline(always)]
static pure fn from_str_radix(val: &str, radix: uint) -> Option<float> { static pure fn from_str_radix(val: &str, radix: uint) -> Option<float> {
from_str_radix(val, radix) from_str_radix(val, radix)
@ -392,25 +392,25 @@ pub pure fn tan(x: float) -> float {
} }
#[cfg(notest)] #[cfg(notest)]
impl float : Eq { impl Eq for float {
pure fn eq(&self, other: &float) -> bool { (*self) == (*other) } pure fn eq(&self, other: &float) -> bool { (*self) == (*other) }
pure fn ne(&self, other: &float) -> bool { (*self) != (*other) } pure fn ne(&self, other: &float) -> bool { (*self) != (*other) }
} }
#[cfg(notest)] #[cfg(notest)]
impl float : Ord { impl Ord for float {
pure fn lt(&self, other: &float) -> bool { (*self) < (*other) } pure fn lt(&self, other: &float) -> bool { (*self) < (*other) }
pure fn le(&self, other: &float) -> bool { (*self) <= (*other) } pure fn le(&self, other: &float) -> bool { (*self) <= (*other) }
pure fn ge(&self, other: &float) -> bool { (*self) >= (*other) } pure fn ge(&self, other: &float) -> bool { (*self) >= (*other) }
pure fn gt(&self, other: &float) -> bool { (*self) > (*other) } pure fn gt(&self, other: &float) -> bool { (*self) > (*other) }
} }
impl float: num::Zero { impl num::Zero for float {
#[inline(always)] #[inline(always)]
static pure fn zero() -> float { 0.0 } static pure fn zero() -> float { 0.0 }
} }
impl float: num::One { impl num::One for float {
#[inline(always)] #[inline(always)]
static pure fn one() -> float { 1.0 } static pure fn one() -> float { 1.0 }
} }
@ -439,7 +439,7 @@ pub impl float: NumCast {
#[inline(always)] pure fn to_float(&self) -> float { *self } #[inline(always)] pure fn to_float(&self) -> float { *self }
} }
impl float: num::Round { impl num::Round for float {
#[inline(always)] #[inline(always)]
pure fn round(&self, mode: num::RoundMode) -> float { pure fn round(&self, mode: num::RoundMode) -> float {
match mode { match mode {

View file

@ -147,7 +147,7 @@ pub pure fn abs(i: T) -> T {
} }
#[cfg(notest)] #[cfg(notest)]
impl T : Ord { impl Ord for T {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &T) -> bool { return (*self) < (*other); } pure fn lt(&self, other: &T) -> bool { return (*self) < (*other); }
#[inline(always)] #[inline(always)]
@ -159,24 +159,24 @@ impl T : Ord {
} }
#[cfg(notest)] #[cfg(notest)]
impl T : Eq { impl Eq for T {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); } pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); }
#[inline(always)] #[inline(always)]
pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); } pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); }
} }
impl T: num::Zero { impl num::Zero for T {
#[inline(always)] #[inline(always)]
static pure fn zero() -> T { 0 } static pure fn zero() -> T { 0 }
} }
impl T: num::One { impl num::One for T {
#[inline(always)] #[inline(always)]
static pure fn one() -> T { 1 } static pure fn one() -> T { 1 }
} }
impl T: num::Round { impl num::Round for T {
#[inline(always)] #[inline(always)]
pure fn round(&self, _: num::RoundMode) -> T { *self } pure fn round(&self, _: num::RoundMode) -> T { *self }
@ -236,14 +236,14 @@ pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
num::ExpNone, false) num::ExpNone, false)
} }
impl T : FromStr { impl FromStr for T {
#[inline(always)] #[inline(always)]
static pure fn from_str(s: &str) -> Option<T> { static pure fn from_str(s: &str) -> Option<T> {
from_str(s) from_str(s)
} }
} }
impl T : FromStrRadix { impl FromStrRadix for T {
#[inline(always)] #[inline(always)]
static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> { static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> {
from_str_radix(s, radix) from_str_radix(s, radix)
@ -281,14 +281,14 @@ pub pure fn to_str_radix(num: T, radix: uint) -> ~str {
#[inline(always)] #[inline(always)]
pub pure fn str(i: T) -> ~str { to_str(i) } pub pure fn str(i: T) -> ~str { to_str(i) }
impl T : ToStr { impl ToStr for T {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
to_str(*self) to_str(*self)
} }
} }
impl T : ToStrRadix { impl ToStrRadix for T {
#[inline(always)] #[inline(always)]
pure fn to_str_radix(&self, radix: uint) -> ~str { pure fn to_str_radix(&self, radix: uint) -> ~str {
to_str_radix(*self, radix) to_str_radix(*self, radix)

View file

@ -111,7 +111,7 @@ pub pure fn compl(i: T) -> T {
} }
#[cfg(notest)] #[cfg(notest)]
impl T : Ord { impl Ord for T {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &T) -> bool { (*self) < (*other) } pure fn lt(&self, other: &T) -> bool { (*self) < (*other) }
#[inline(always)] #[inline(always)]
@ -123,24 +123,24 @@ impl T : Ord {
} }
#[cfg(notest)] #[cfg(notest)]
impl T : Eq { impl Eq for T {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); } pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); }
#[inline(always)] #[inline(always)]
pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); } pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); }
} }
impl T: num::Zero { impl num::Zero for T {
#[inline(always)] #[inline(always)]
static pure fn zero() -> T { 0 } static pure fn zero() -> T { 0 }
} }
impl T: num::One { impl num::One for T {
#[inline(always)] #[inline(always)]
static pure fn one() -> T { 1 } static pure fn one() -> T { 1 }
} }
impl T: num::Round { impl num::Round for T {
#[inline(always)] #[inline(always)]
pure fn round(&self, _: num::RoundMode) -> T { *self } pure fn round(&self, _: num::RoundMode) -> T { *self }
@ -200,14 +200,14 @@ pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
num::ExpNone, false) num::ExpNone, false)
} }
impl T : FromStr { impl FromStr for T {
#[inline(always)] #[inline(always)]
static pure fn from_str(s: &str) -> Option<T> { static pure fn from_str(s: &str) -> Option<T> {
from_str(s) from_str(s)
} }
} }
impl T : FromStrRadix { impl FromStrRadix for T {
#[inline(always)] #[inline(always)]
static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> { static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> {
from_str_radix(s, radix) from_str_radix(s, radix)
@ -245,14 +245,14 @@ pub pure fn to_str_radix(num: T, radix: uint) -> ~str {
#[inline(always)] #[inline(always)]
pub pure fn str(i: T) -> ~str { to_str(i) } pub pure fn str(i: T) -> ~str { to_str(i) }
impl T : ToStr { impl ToStr for T {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
to_str(*self) to_str(*self)
} }
} }
impl T : ToStrRadix { impl ToStrRadix for T {
#[inline(always)] #[inline(always)]
pure fn to_str_radix(&self, radix: uint) -> ~str { pure fn to_str_radix(&self, radix: uint) -> ~str {
to_str_radix(*self, radix) to_str_radix(*self, radix)

View file

@ -13,7 +13,7 @@
use cmp::{Eq, Ord}; use cmp::{Eq, Ord};
#[cfg(notest)] #[cfg(notest)]
impl<T:Eq> ~const T : Eq { impl<T:Eq> Eq for ~const T {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &~const T) -> bool { *(*self) == *(*other) } pure fn eq(&self, other: &~const T) -> bool { *(*self) == *(*other) }
#[inline(always)] #[inline(always)]
@ -21,7 +21,7 @@ impl<T:Eq> ~const T : Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl<T:Ord> ~const T : Ord { impl<T:Ord> Ord for ~const T {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &~const T) -> bool { *(*self) < *(*other) } pure fn lt(&self, other: &~const T) -> bool { *(*self) < *(*other) }
#[inline(always)] #[inline(always)]

View file

@ -363,7 +363,7 @@ impl Path {
} }
} }
impl PosixPath : ToStr { impl ToStr for PosixPath {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
let mut s = ~""; let mut s = ~"";
if self.is_absolute { if self.is_absolute {
@ -375,7 +375,7 @@ impl PosixPath : ToStr {
// FIXME (#3227): when default methods in traits are working, de-duplicate // FIXME (#3227): when default methods in traits are working, de-duplicate
// PosixPath and WindowsPath, most of their methods are common. // PosixPath and WindowsPath, most of their methods are common.
impl PosixPath : GenericPath { impl GenericPath for PosixPath {
static pure fn from_str(s: &str) -> PosixPath { static pure fn from_str(s: &str) -> PosixPath {
let mut components = str::split_nonempty(s, |c| c == '/'); let mut components = str::split_nonempty(s, |c| c == '/');
@ -526,7 +526,7 @@ impl PosixPath : GenericPath {
} }
impl WindowsPath : ToStr { impl ToStr for WindowsPath {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
let mut s = ~""; let mut s = ~"";
match self.host { match self.host {
@ -545,7 +545,7 @@ impl WindowsPath : ToStr {
} }
impl WindowsPath : GenericPath { impl GenericPath for WindowsPath {
static pure fn from_str(s: &str) -> WindowsPath { static pure fn from_str(s: &str) -> WindowsPath {
let host; let host;

View file

@ -112,7 +112,7 @@ enum State {
Terminated Terminated
} }
impl State : Eq { impl Eq for State {
pure fn eq(&self, other: &State) -> bool { pure fn eq(&self, other: &State) -> bool {
((*self) as uint) == ((*other) as uint) ((*self) as uint) == ((*other) as uint)
} }
@ -207,7 +207,7 @@ pub trait HasBuffer {
fn set_buffer(b: *libc::c_void); fn set_buffer(b: *libc::c_void);
} }
impl<T: Owned> Packet<T>: HasBuffer { impl<T: Owned> HasBuffer for Packet<T> {
fn set_buffer(b: *libc::c_void) { fn set_buffer(b: *libc::c_void) {
self.header.buffer = b; self.header.buffer = b;
} }
@ -561,7 +561,7 @@ pub pure fn peek<T: Owned, Tb: Owned>(p: &RecvPacketBuffered<T, Tb>) -> bool {
} }
} }
impl<T: Owned, Tb: Owned> RecvPacketBuffered<T, Tb>: Peekable<T> { impl<T: Owned, Tb: Owned> Peekable<T> for RecvPacketBuffered<T, Tb> {
pure fn peek() -> bool { pure fn peek() -> bool {
peek(&self) peek(&self)
} }
@ -734,7 +734,7 @@ trait Selectable {
pure fn header() -> *PacketHeader; pure fn header() -> *PacketHeader;
} }
impl *PacketHeader: Selectable { impl Selectable for *PacketHeader {
pure fn header() -> *PacketHeader { self } pure fn header() -> *PacketHeader { self }
} }
@ -783,7 +783,7 @@ pub struct SendPacketBuffered<T, Tbuffer> {
mut buffer: Option<BufferResource<Tbuffer>>, mut buffer: Option<BufferResource<Tbuffer>>,
} }
impl<T:Owned,Tbuffer:Owned> SendPacketBuffered<T,Tbuffer> : ::ops::Drop { impl<T:Owned,Tbuffer:Owned> ::ops::Drop for SendPacketBuffered<T,Tbuffer> {
fn finalize(&self) { fn finalize(&self) {
//if self.p != none { //if self.p != none {
// debug!("drop send %?", option::get(self.p)); // debug!("drop send %?", option::get(self.p));
@ -852,7 +852,7 @@ pub struct RecvPacketBuffered<T, Tbuffer> {
mut buffer: Option<BufferResource<Tbuffer>>, mut buffer: Option<BufferResource<Tbuffer>>,
} }
impl<T:Owned, Tbuffer:Owned> RecvPacketBuffered<T,Tbuffer> : ::ops::Drop { impl<T:Owned, Tbuffer:Owned> ::ops::Drop for RecvPacketBuffered<T,Tbuffer> {
fn finalize(&self) { fn finalize(&self) {
//if self.p != none { //if self.p != none {
// debug!("drop recv %?", option::get(self.p)); // debug!("drop recv %?", option::get(self.p));
@ -884,7 +884,7 @@ impl<T: Owned, Tbuffer: Owned> RecvPacketBuffered<T, Tbuffer> {
} }
} }
impl<T: Owned, Tbuffer: Owned> RecvPacketBuffered<T, Tbuffer> : Selectable { impl<T: Owned, Tbuffer: Owned> Selectable for RecvPacketBuffered<T, Tbuffer> {
pure fn header() -> *PacketHeader { pure fn header() -> *PacketHeader {
match self.p { match self.p {
Some(packet) => unsafe { Some(packet) => unsafe {
@ -1036,7 +1036,7 @@ pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
(Port_(Port_ { endp: Some(s) }), Chan_(Chan_{ endp: Some(c) })) (Port_(Port_ { endp: Some(s) }), Chan_(Chan_{ endp: Some(c) }))
} }
impl<T: Owned> Chan<T>: GenericChan<T> { impl<T: Owned> GenericChan<T> for Chan<T> {
fn send(x: T) { fn send(x: T) {
let mut endp = None; let mut endp = None;
endp <-> self.endp; endp <-> self.endp;
@ -1045,7 +1045,7 @@ impl<T: Owned> Chan<T>: GenericChan<T> {
} }
} }
impl<T: Owned> Chan<T>: GenericSmartChan<T> { impl<T: Owned> GenericSmartChan<T> for Chan<T> {
fn try_send(x: T) -> bool { fn try_send(x: T) -> bool {
let mut endp = None; let mut endp = None;
@ -1060,7 +1060,7 @@ impl<T: Owned> Chan<T>: GenericSmartChan<T> {
} }
} }
impl<T: Owned> Port<T>: GenericPort<T> { impl<T: Owned> GenericPort<T> for Port<T> {
fn recv() -> T { fn recv() -> T {
let mut endp = None; let mut endp = None;
endp <-> self.endp; endp <-> self.endp;
@ -1082,7 +1082,7 @@ impl<T: Owned> Port<T>: GenericPort<T> {
} }
} }
impl<T: Owned> Port<T>: Peekable<T> { impl<T: Owned> Peekable<T> for Port<T> {
pure fn peek() -> bool { pure fn peek() -> bool {
unsafe { unsafe {
let mut endp = None; let mut endp = None;
@ -1097,7 +1097,7 @@ impl<T: Owned> Port<T>: Peekable<T> {
} }
} }
impl<T: Owned> Port<T>: Selectable { impl<T: Owned> Selectable for Port<T> {
pure fn header() -> *PacketHeader { pure fn header() -> *PacketHeader {
unsafe { unsafe {
match self.endp { match self.endp {
@ -1132,7 +1132,7 @@ impl<T: Owned> PortSet<T> {
} }
} }
impl<T: Owned> PortSet<T> : GenericPort<T> { impl<T: Owned> GenericPort<T> for PortSet<T> {
fn try_recv() -> Option<T> { fn try_recv() -> Option<T> {
let mut result = None; let mut result = None;
@ -1162,7 +1162,7 @@ impl<T: Owned> PortSet<T> : GenericPort<T> {
} }
impl<T: Owned> PortSet<T> : Peekable<T> { impl<T: Owned> Peekable<T> for PortSet<T> {
pure fn peek() -> bool { pure fn peek() -> bool {
// It'd be nice to use self.port.each, but that version isn't // It'd be nice to use self.port.each, but that version isn't
// pure. // pure.
@ -1176,7 +1176,7 @@ impl<T: Owned> PortSet<T> : Peekable<T> {
/// A channel that can be shared between many senders. /// A channel that can be shared between many senders.
pub type SharedChan<T> = private::Exclusive<Chan<T>>; pub type SharedChan<T> = private::Exclusive<Chan<T>>;
impl<T: Owned> SharedChan<T>: GenericChan<T> { impl<T: Owned> GenericChan<T> for SharedChan<T> {
fn send(x: T) { fn send(x: T) {
let mut xx = Some(move x); let mut xx = Some(move x);
do self.with_imm |chan| { do self.with_imm |chan| {
@ -1187,7 +1187,7 @@ impl<T: Owned> SharedChan<T>: GenericChan<T> {
} }
} }
impl<T: Owned> SharedChan<T>: GenericSmartChan<T> { impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
fn try_send(x: T) -> bool { fn try_send(x: T) -> bool {
let mut xx = Some(move x); let mut xx = Some(move x);
do self.with_imm |chan| { do self.with_imm |chan| {

View file

@ -291,7 +291,7 @@ pub unsafe fn clone_shared_mutable_state<T: Owned>(rc: &SharedMutableState<T>)
ArcDestruct((*rc).data) ArcDestruct((*rc).data)
} }
impl<T: Owned> SharedMutableState<T>: Clone { impl<T: Owned> Clone for SharedMutableState<T> {
fn clone(&self) -> SharedMutableState<T> { fn clone(&self) -> SharedMutableState<T> {
unsafe { unsafe {
clone_shared_mutable_state(self) clone_shared_mutable_state(self)
@ -360,7 +360,7 @@ pub fn exclusive<T:Owned >(user_data: T) -> Exclusive<T> {
Exclusive { x: unsafe { shared_mutable_state(move data) } } Exclusive { x: unsafe { shared_mutable_state(move data) } }
} }
impl<T: Owned> Exclusive<T>: Clone { impl<T: Owned> Clone for Exclusive<T> {
// Duplicate an exclusive ARC, as std::arc::clone. // Duplicate an exclusive ARC, as std::arc::clone.
fn clone(&self) -> Exclusive<T> { fn clone(&self) -> Exclusive<T> {
Exclusive { x: unsafe { clone_shared_mutable_state(&self.x) } } Exclusive { x: unsafe { clone_shared_mutable_state(&self.x) } }

View file

@ -39,7 +39,7 @@ pub trait Finally<T> {
} }
#[cfg(stage0)] #[cfg(stage0)]
impl<T> &fn() -> T: Finally<T> { impl<T> Finally<T> for &fn() -> T {
// FIXME #4518: Should not require a mode here // FIXME #4518: Should not require a mode here
fn finally(&self, +dtor: &fn()) -> T { fn finally(&self, +dtor: &fn()) -> T {
let _d = Finallyalizer { let _d = Finallyalizer {
@ -53,7 +53,7 @@ impl<T> &fn() -> T: Finally<T> {
#[cfg(stage1)] #[cfg(stage1)]
#[cfg(stage2)] #[cfg(stage2)]
#[cfg(stage3)] #[cfg(stage3)]
impl<T> &fn() -> T: Finally<T> { impl<T> Finally<T> for &fn() -> T {
fn finally(&self, dtor: &fn()) -> T { fn finally(&self, dtor: &fn()) -> T {
let _d = Finallyalizer { let _d = Finallyalizer {
dtor: dtor dtor: dtor
@ -67,7 +67,7 @@ struct Finallyalizer {
dtor: &fn() dtor: &fn()
} }
impl Finallyalizer: Drop { impl Drop for Finallyalizer {
fn finalize(&self) { fn finalize(&self) {
(self.dtor)(); (self.dtor)();
} }

View file

@ -146,7 +146,7 @@ struct GlobalState {
map: LinearMap<uint, (*c_void, ~fn())> map: LinearMap<uint, (*c_void, ~fn())>
} }
impl GlobalState: Drop { impl Drop for GlobalState {
fn finalize(&self) { fn finalize(&self) {
for self.map.each_value |v| { for self.map.each_value |v| {
match v { match v {

View file

@ -194,7 +194,7 @@ pub extern {
} }
/// Extension methods for immutable pointers /// Extension methods for immutable pointers
impl<T> *T: Ptr<T> { impl<T> Ptr<T> for *T {
/// Returns true if the pointer is equal to the null pointer. /// Returns true if the pointer is equal to the null pointer.
#[inline(always)] #[inline(always)]
pure fn is_null() -> bool { is_null(self) } pure fn is_null() -> bool { is_null(self) }
@ -209,7 +209,7 @@ impl<T> *T: Ptr<T> {
} }
/// Extension methods for mutable pointers /// Extension methods for mutable pointers
impl<T> *mut T: Ptr<T> { impl<T> Ptr<T> for *mut T {
/// Returns true if the pointer is equal to the null pointer. /// Returns true if the pointer is equal to the null pointer.
#[inline(always)] #[inline(always)]
pure fn is_null() -> bool { is_null(self) } pure fn is_null() -> bool { is_null(self) }
@ -225,7 +225,7 @@ impl<T> *mut T: Ptr<T> {
// Equality for pointers // Equality for pointers
#[cfg(notest)] #[cfg(notest)]
impl<T> *const T : Eq { impl<T> Eq for *const T {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &*const T) -> bool { pure fn eq(&self, other: &*const T) -> bool {
unsafe { unsafe {
@ -240,7 +240,7 @@ impl<T> *const T : Eq {
// Comparison for pointers // Comparison for pointers
#[cfg(notest)] #[cfg(notest)]
impl<T> *const T : Ord { impl<T> Ord for *const T {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &*const T) -> bool { pure fn lt(&self, other: &*const T) -> bool {
unsafe { unsafe {
@ -277,7 +277,7 @@ impl<T> *const T : Ord {
// Equality for region pointers // Equality for region pointers
#[cfg(notest)] #[cfg(notest)]
impl<T:Eq> &const T : Eq { impl<T:Eq> Eq for &const T {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: & &self/const T) -> bool { pure fn eq(&self, other: & &self/const T) -> bool {
return *(*self) == *(*other); return *(*self) == *(*other);
@ -290,7 +290,7 @@ impl<T:Eq> &const T : Eq {
// Comparison for region pointers // Comparison for region pointers
#[cfg(notest)] #[cfg(notest)]
impl<T:Ord> &const T : Ord { impl<T:Ord> Ord for &const T {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: & &self/const T) -> bool { pure fn lt(&self, other: & &self/const T) -> bool {
*(*self) < *(*other) *(*self) < *(*other)

View file

@ -24,91 +24,91 @@ pub trait Rand {
static fn rand(rng: rand::Rng) -> Self; static fn rand(rng: rand::Rng) -> Self;
} }
impl int: Rand { impl Rand for int {
static fn rand(rng: rand::Rng) -> int { static fn rand(rng: rand::Rng) -> int {
rng.gen_int() rng.gen_int()
} }
} }
impl i8: Rand { impl Rand for i8 {
static fn rand(rng: rand::Rng) -> i8 { static fn rand(rng: rand::Rng) -> i8 {
rng.gen_i8() rng.gen_i8()
} }
} }
impl i16: Rand { impl Rand for i16 {
static fn rand(rng: rand::Rng) -> i16 { static fn rand(rng: rand::Rng) -> i16 {
rng.gen_i16() rng.gen_i16()
} }
} }
impl i32: Rand { impl Rand for i32 {
static fn rand(rng: rand::Rng) -> i32 { static fn rand(rng: rand::Rng) -> i32 {
rng.gen_i32() rng.gen_i32()
} }
} }
impl i64: Rand { impl Rand for i64 {
static fn rand(rng: rand::Rng) -> i64 { static fn rand(rng: rand::Rng) -> i64 {
rng.gen_i64() rng.gen_i64()
} }
} }
impl u8: Rand { impl Rand for u8 {
static fn rand(rng: rand::Rng) -> u8 { static fn rand(rng: rand::Rng) -> u8 {
rng.gen_u8() rng.gen_u8()
} }
} }
impl u16: Rand { impl Rand for u16 {
static fn rand(rng: rand::Rng) -> u16 { static fn rand(rng: rand::Rng) -> u16 {
rng.gen_u16() rng.gen_u16()
} }
} }
impl u32: Rand { impl Rand for u32 {
static fn rand(rng: rand::Rng) -> u32 { static fn rand(rng: rand::Rng) -> u32 {
rng.gen_u32() rng.gen_u32()
} }
} }
impl u64: Rand { impl Rand for u64 {
static fn rand(rng: rand::Rng) -> u64 { static fn rand(rng: rand::Rng) -> u64 {
rng.gen_u64() rng.gen_u64()
} }
} }
impl float: Rand { impl Rand for float {
static fn rand(rng: rand::Rng) -> float { static fn rand(rng: rand::Rng) -> float {
rng.gen_float() rng.gen_float()
} }
} }
impl f32: Rand { impl Rand for f32 {
static fn rand(rng: rand::Rng) -> f32 { static fn rand(rng: rand::Rng) -> f32 {
rng.gen_f32() rng.gen_f32()
} }
} }
impl f64: Rand { impl Rand for f64 {
static fn rand(rng: rand::Rng) -> f64 { static fn rand(rng: rand::Rng) -> f64 {
rng.gen_f64() rng.gen_f64()
} }
} }
impl char: Rand { impl Rand for char {
static fn rand(rng: rand::Rng) -> char { static fn rand(rng: rand::Rng) -> char {
rng.gen_char() rng.gen_char()
} }
} }
impl bool: Rand { impl Rand for bool {
static fn rand(rng: rand::Rng) -> bool { static fn rand(rng: rand::Rng) -> bool {
rng.gen_bool() rng.gen_bool()
} }
} }
impl<T: Rand> Option<T>: Rand { impl<T: Rand> Rand for Option<T> {
static fn rand(rng: rand::Rng) -> Option<T> { static fn rand(rng: rand::Rng) -> Option<T> {
if rng.gen_bool() { Some(Rand::rand(rng)) } if rng.gen_bool() { Some(Rand::rand(rng)) }
else { None } else { None }
@ -377,7 +377,7 @@ fn RandRes(c: *rctx) -> RandRes {
} }
} }
impl @RandRes: Rng { impl Rng for @RandRes {
fn next() -> u32 { fn next() -> u32 {
unsafe { unsafe {
return rustrt::rand_next((*self).c); return rustrt::rand_next((*self).c);
@ -418,7 +418,7 @@ struct XorShiftState {
mut w: u32, mut w: u32,
} }
impl XorShiftState: Rng { impl Rng for XorShiftState {
fn next() -> u32 { fn next() -> u32 {
let x = self.x; let x = self.x;
let mut t = x ^ (x << 11); let mut t = x ^ (x << 11);

View file

@ -72,7 +72,7 @@ impl<V: TyVisitor MovePtr> MovePtrAdaptor<V> {
} }
/// Abstract type-directed pointer-movement using the MovePtr trait /// Abstract type-directed pointer-movement using the MovePtr trait
impl<V: TyVisitor MovePtr> MovePtrAdaptor<V>: TyVisitor { impl<V: TyVisitor MovePtr> TyVisitor for MovePtrAdaptor<V> {
fn visit_bot(&self) -> bool { fn visit_bot(&self) -> bool {
self.align_to::<()>(); self.align_to::<()>();
if ! self.inner.visit_bot() { return false; } if ! self.inner.visit_bot() { return false; }

View file

@ -46,7 +46,7 @@ trait EscapedCharWriter {
fn write_escaped_char(ch: char); fn write_escaped_char(ch: char);
} }
impl Writer : EscapedCharWriter { impl EscapedCharWriter for Writer {
fn write_escaped_char(ch: char) { fn write_escaped_char(ch: char) {
match ch { match ch {
'\t' => self.write_str("\\t"), '\t' => self.write_str("\\t"),
@ -71,64 +71,64 @@ trait Repr {
fn write_repr(writer: @Writer); fn write_repr(writer: @Writer);
} }
impl () : Repr { impl Repr for () {
fn write_repr(writer: @Writer) { writer.write_str("()"); } fn write_repr(writer: @Writer) { writer.write_str("()"); }
} }
impl bool : Repr { impl Repr for bool {
fn write_repr(writer: @Writer) { fn write_repr(writer: @Writer) {
writer.write_str(if self { "true" } else { "false" }) writer.write_str(if self { "true" } else { "false" })
} }
} }
impl int : Repr { impl Repr for int {
fn write_repr(writer: @Writer) { writer.write_int(self); } fn write_repr(writer: @Writer) { writer.write_int(self); }
} }
impl i8 : Repr { impl Repr for i8 {
fn write_repr(writer: @Writer) { writer.write_int(self as int); } fn write_repr(writer: @Writer) { writer.write_int(self as int); }
} }
impl i16 : Repr { impl Repr for i16 {
fn write_repr(writer: @Writer) { writer.write_int(self as int); } fn write_repr(writer: @Writer) { writer.write_int(self as int); }
} }
impl i32 : Repr { impl Repr for i32 {
fn write_repr(writer: @Writer) { writer.write_int(self as int); } fn write_repr(writer: @Writer) { writer.write_int(self as int); }
} }
impl i64 : Repr { impl Repr for i64 {
// FIXME #4424: This can lose precision. // FIXME #4424: This can lose precision.
fn write_repr(writer: @Writer) { writer.write_int(self as int); } fn write_repr(writer: @Writer) { writer.write_int(self as int); }
} }
impl uint : Repr { impl Repr for uint {
fn write_repr(writer: @Writer) { writer.write_uint(self); } fn write_repr(writer: @Writer) { writer.write_uint(self); }
} }
impl u8 : Repr { impl Repr for u8 {
fn write_repr(writer: @Writer) { writer.write_uint(self as uint); } fn write_repr(writer: @Writer) { writer.write_uint(self as uint); }
} }
impl u16 : Repr { impl Repr for u16 {
fn write_repr(writer: @Writer) { writer.write_uint(self as uint); } fn write_repr(writer: @Writer) { writer.write_uint(self as uint); }
} }
impl u32 : Repr { impl Repr for u32 {
fn write_repr(writer: @Writer) { writer.write_uint(self as uint); } fn write_repr(writer: @Writer) { writer.write_uint(self as uint); }
} }
impl u64 : Repr { impl Repr for u64 {
// FIXME #4424: This can lose precision. // FIXME #4424: This can lose precision.
fn write_repr(writer: @Writer) { writer.write_uint(self as uint); } fn write_repr(writer: @Writer) { writer.write_uint(self as uint); }
} }
impl float : Repr { impl Repr for float {
// FIXME #4423: This mallocs. // FIXME #4423: This mallocs.
fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); } fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); }
} }
impl f32 : Repr { impl Repr for f32 {
// FIXME #4423 This mallocs. // FIXME #4423 This mallocs.
fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); } fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); }
} }
impl f64 : Repr { impl Repr for f64 {
// FIXME #4423: This mallocs. // FIXME #4423: This mallocs.
fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); } fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); }
} }
impl char : Repr { impl Repr for char {
fn write_repr(writer: @Writer) { writer.write_char(self); } fn write_repr(writer: @Writer) { writer.write_char(self); }
} }
@ -154,7 +154,7 @@ pub fn ReprVisitor(ptr: *c_void, writer: @Writer) -> ReprVisitor {
writer: writer } writer: writer }
} }
impl ReprVisitor : MovePtr { impl MovePtr for ReprVisitor {
#[inline(always)] #[inline(always)]
fn move_ptr(adjustment: fn(*c_void) -> *c_void) { fn move_ptr(adjustment: fn(*c_void) -> *c_void) {
self.ptr = adjustment(self.ptr); self.ptr = adjustment(self.ptr);
@ -262,7 +262,7 @@ impl ReprVisitor {
} }
impl ReprVisitor : TyVisitor { impl TyVisitor for ReprVisitor {
fn visit_bot(&self) -> bool { fn visit_bot(&self) -> bool {
self.writer.write_str("!"); self.writer.write_str("!");
true true

View file

@ -262,7 +262,7 @@ pub fn start_program(prog: &str, args: &[~str]) -> Program {
} }
} }
impl ProgRes: Program { impl Program for ProgRes {
fn get_id(&mut self) -> pid_t { return self.r.pid; } fn get_id(&mut self) -> pid_t { return self.r.pid; }
fn input(&mut self) -> io::Writer { fn input(&mut self) -> io::Writer {
io::fd_writer(self.r.in_fd, false) io::fd_writer(self.r.in_fd, false)

View file

@ -771,7 +771,7 @@ pure fn gt(a: &str, b: &str) -> bool {
} }
#[cfg(notest)] #[cfg(notest)]
impl &str : Eq { impl Eq for &str {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: & &self/str) -> bool { pure fn eq(&self, other: & &self/str) -> bool {
eq_slice((*self), (*other)) eq_slice((*self), (*other))
@ -781,7 +781,7 @@ impl &str : Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl ~str : Eq { impl Eq for ~str {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &~str) -> bool { pure fn eq(&self, other: &~str) -> bool {
eq_slice((*self), (*other)) eq_slice((*self), (*other))
@ -791,7 +791,7 @@ impl ~str : Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl @str : Eq { impl Eq for @str {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &@str) -> bool { pure fn eq(&self, other: &@str) -> bool {
eq_slice((*self), (*other)) eq_slice((*self), (*other))
@ -801,7 +801,7 @@ impl @str : Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl ~str : Ord { impl Ord for ~str {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &~str) -> bool { lt((*self), (*other)) } pure fn lt(&self, other: &~str) -> bool { lt((*self), (*other)) }
#[inline(always)] #[inline(always)]
@ -813,7 +813,7 @@ impl ~str : Ord {
} }
#[cfg(notest)] #[cfg(notest)]
impl &str : Ord { impl Ord for &str {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: & &self/str) -> bool { lt((*self), (*other)) } pure fn lt(&self, other: & &self/str) -> bool { lt((*self), (*other)) }
#[inline(always)] #[inline(always)]
@ -825,7 +825,7 @@ impl &str : Ord {
} }
#[cfg(notest)] #[cfg(notest)]
impl @str : Ord { impl Ord for @str {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &@str) -> bool { lt((*self), (*other)) } pure fn lt(&self, other: &@str) -> bool { lt((*self), (*other)) }
#[inline(always)] #[inline(always)]
@ -2134,7 +2134,7 @@ pub trait Trimmable {
} }
/// Extension methods for strings /// Extension methods for strings
impl ~str: Trimmable { impl Trimmable for ~str {
/// Returns a string with leading and trailing whitespace removed /// Returns a string with leading and trailing whitespace removed
#[inline] #[inline]
pure fn trim() -> ~str { trim(self) } pure fn trim() -> ~str { trim(self) }
@ -2151,7 +2151,7 @@ pub mod traits {
use ops::Add; use ops::Add;
use str::append; use str::append;
impl ~str : Add<&str,~str> { impl Add<&str,~str> for ~str {
#[inline(always)] #[inline(always)]
pure fn add(&self, rhs: & &self/str) -> ~str { pure fn add(&self, rhs: & &self/str) -> ~str {
append(copy *self, (*rhs)) append(copy *self, (*rhs))
@ -2195,7 +2195,7 @@ pub trait StrSlice {
} }
/// Extension methods for strings /// Extension methods for strings
impl &str: StrSlice { impl StrSlice for &str {
/** /**
* Return true if a predicate matches all characters or if the string * Return true if a predicate matches all characters or if the string
* contains no characters * contains no characters

View file

@ -26,9 +26,9 @@ use rt::rust_task;
type rust_task = libc::c_void; type rust_task = libc::c_void;
pub trait LocalData { } pub trait LocalData { }
impl<T: Durable> @T: LocalData { } impl<T: Durable> LocalData for @T { }
impl LocalData: Eq { impl Eq for LocalData {
pure fn eq(&self, other: &@LocalData) -> bool { pure fn eq(&self, other: &@LocalData) -> bool {
unsafe { unsafe {
let ptr_a: (uint, uint) = cast::reinterpret_cast(&(*self)); let ptr_a: (uint, uint) = cast::reinterpret_cast(&(*self));

View file

@ -84,7 +84,7 @@ pub enum TaskResult {
Failure, Failure,
} }
impl TaskResult : Eq { impl Eq for TaskResult {
pure fn eq(&self, other: &TaskResult) -> bool { pure fn eq(&self, other: &TaskResult) -> bool {
match ((*self), (*other)) { match ((*self), (*other)) {
(Success, Success) | (Failure, Failure) => true, (Success, Success) | (Failure, Failure) => true,

View file

@ -46,7 +46,7 @@ pub trait IterBytes {
pure fn iter_bytes(&self, lsb0: bool, f: Cb); pure fn iter_bytes(&self, lsb0: bool, f: Cb);
} }
impl bool: IterBytes { impl IterBytes for bool {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) { pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
f([ f([
@ -55,7 +55,7 @@ impl bool: IterBytes {
} }
} }
impl u8: IterBytes { impl IterBytes for u8 {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) { pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
f([ f([
@ -64,7 +64,7 @@ impl u8: IterBytes {
} }
} }
impl u16: IterBytes { impl IterBytes for u16 {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
if lsb0 { if lsb0 {
@ -81,7 +81,7 @@ impl u16: IterBytes {
} }
} }
impl u32: IterBytes { impl IterBytes for u32 {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
if lsb0 { if lsb0 {
@ -102,7 +102,7 @@ impl u32: IterBytes {
} }
} }
impl u64: IterBytes { impl IterBytes for u64 {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
if lsb0 { if lsb0 {
@ -131,35 +131,35 @@ impl u64: IterBytes {
} }
} }
impl i8: IterBytes { impl IterBytes for i8 {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u8).iter_bytes(lsb0, f) (*self as u8).iter_bytes(lsb0, f)
} }
} }
impl i16: IterBytes { impl IterBytes for i16 {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u16).iter_bytes(lsb0, f) (*self as u16).iter_bytes(lsb0, f)
} }
} }
impl i32: IterBytes { impl IterBytes for i32 {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u32).iter_bytes(lsb0, f) (*self as u32).iter_bytes(lsb0, f)
} }
} }
impl i64: IterBytes { impl IterBytes for i64 {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u64).iter_bytes(lsb0, f) (*self as u64).iter_bytes(lsb0, f)
} }
} }
impl char: IterBytes { impl IterBytes for char {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u32).iter_bytes(lsb0, f) (*self as u32).iter_bytes(lsb0, f)
@ -190,14 +190,14 @@ pub mod x64 {
} }
} }
impl int: IterBytes { impl IterBytes for int {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as uint).iter_bytes(lsb0, f) (*self as uint).iter_bytes(lsb0, f)
} }
} }
impl<A: IterBytes> &[A]: IterBytes { impl<A: IterBytes> IterBytes for &[A] {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
for (*self).each |elt| { for (*self).each |elt| {
@ -208,7 +208,7 @@ impl<A: IterBytes> &[A]: IterBytes {
} }
} }
impl<A: IterBytes, B: IterBytes> (A,B): IterBytes { impl<A: IterBytes, B: IterBytes> IterBytes for (A,B) {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
match *self { match *self {
@ -219,7 +219,7 @@ impl<A: IterBytes, B: IterBytes> (A,B): IterBytes {
} }
} }
impl<A: IterBytes, B: IterBytes, C: IterBytes> (A,B,C): IterBytes { impl<A: IterBytes, B: IterBytes, C: IterBytes> IterBytes for (A,B,C) {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
match *self { match *self {
@ -235,14 +235,14 @@ pure fn borrow<A>(a: &x/[A]) -> &x/[A] {
a a
} }
impl<A: IterBytes> ~[A]: IterBytes { impl<A: IterBytes> IterBytes for ~[A] {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
borrow(*self).iter_bytes(lsb0, f) borrow(*self).iter_bytes(lsb0, f)
} }
} }
impl<A: IterBytes> @[A]: IterBytes { impl<A: IterBytes> IterBytes for @[A] {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
borrow(*self).iter_bytes(lsb0, f) borrow(*self).iter_bytes(lsb0, f)
@ -352,7 +352,7 @@ pub pure fn iter_bytes_7<A: IterBytes,
g.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); g.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
} }
impl &str: IterBytes { impl IterBytes for &str {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) { pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
do str::byte_slice(*self) |bytes| { do str::byte_slice(*self) |bytes| {
@ -361,7 +361,7 @@ impl &str: IterBytes {
} }
} }
impl ~str: IterBytes { impl IterBytes for ~str {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) { pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
do str::byte_slice(*self) |bytes| { do str::byte_slice(*self) |bytes| {
@ -370,7 +370,7 @@ impl ~str: IterBytes {
} }
} }
impl @str: IterBytes { impl IterBytes for @str {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) { pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
do str::byte_slice(*self) |bytes| { do str::byte_slice(*self) |bytes| {
@ -379,7 +379,7 @@ impl @str: IterBytes {
} }
} }
impl<A: IterBytes> Option<A>: IterBytes { impl<A: IterBytes> IterBytes for Option<A> {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
match *self { match *self {
@ -389,21 +389,21 @@ impl<A: IterBytes> Option<A>: IterBytes {
} }
} }
impl<A: IterBytes> &A: IterBytes { impl<A: IterBytes> IterBytes for &A {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(**self).iter_bytes(lsb0, f); (**self).iter_bytes(lsb0, f);
} }
} }
impl<A: IterBytes> @A: IterBytes { impl<A: IterBytes> IterBytes for @A {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(**self).iter_bytes(lsb0, f); (**self).iter_bytes(lsb0, f);
} }
} }
impl<A: IterBytes> ~A: IterBytes { impl<A: IterBytes> IterBytes for ~A {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(**self).iter_bytes(lsb0, f); (**self).iter_bytes(lsb0, f);
@ -412,7 +412,7 @@ impl<A: IterBytes> ~A: IterBytes {
// NB: raw-pointer IterBytes does _not_ dereference // NB: raw-pointer IterBytes does _not_ dereference
// to the target; it just gives you the pointer-bytes. // to the target; it just gives you the pointer-bytes.
impl<A> *const A: IterBytes { impl<A> IterBytes for *const A {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) { pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as uint).iter_bytes(lsb0, f); (*self as uint).iter_bytes(lsb0, f);
@ -424,7 +424,7 @@ trait ToBytes {
fn to_bytes(&self, lsb0: bool) -> ~[u8]; fn to_bytes(&self, lsb0: bool) -> ~[u8];
} }
impl<A: IterBytes> A: ToBytes { impl<A: IterBytes> ToBytes for A {
fn to_bytes(&self, lsb0: bool) -> ~[u8] { fn to_bytes(&self, lsb0: bool) -> ~[u8] {
do io::with_bytes_writer |wr| { do io::with_bytes_writer |wr| {
for self.iter_bytes(lsb0) |bytes| { for self.iter_bytes(lsb0) |bytes| {

View file

@ -22,28 +22,28 @@ pub trait ToStr {
pure fn to_str(&self) -> ~str; pure fn to_str(&self) -> ~str;
} }
impl bool: ToStr { impl ToStr for bool {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { ::bool::to_str(*self) } pure fn to_str(&self) -> ~str { ::bool::to_str(*self) }
} }
impl (): ToStr { impl ToStr for () {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { ~"()" } pure fn to_str(&self) -> ~str { ~"()" }
} }
impl ~str: ToStr { impl ToStr for ~str {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { copy *self } pure fn to_str(&self) -> ~str { copy *self }
} }
impl &str: ToStr { impl ToStr for &str {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { ::str::from_slice(*self) } pure fn to_str(&self) -> ~str { ::str::from_slice(*self) }
} }
impl @str: ToStr { impl ToStr for @str {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { ::str::from_slice(*self) } pure fn to_str(&self) -> ~str { ::str::from_slice(*self) }
} }
impl<A: ToStr, B: ToStr> (A, B): ToStr { impl<A: ToStr, B: ToStr> ToStr for (A, B) {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
// FIXME(#4760): this causes an llvm assertion // FIXME(#4760): this causes an llvm assertion
@ -55,7 +55,7 @@ impl<A: ToStr, B: ToStr> (A, B): ToStr {
} }
} }
} }
impl<A: ToStr, B: ToStr, C: ToStr> (A, B, C): ToStr { impl<A: ToStr, B: ToStr, C: ToStr> ToStr for (A, B, C) {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
// FIXME(#4760): this causes an llvm assertion // FIXME(#4760): this causes an llvm assertion
@ -72,7 +72,7 @@ impl<A: ToStr, B: ToStr, C: ToStr> (A, B, C): ToStr {
} }
} }
impl<A: ToStr> ~[A]: ToStr { impl<A: ToStr> ToStr for ~[A] {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
unsafe { unsafe {
@ -92,11 +92,11 @@ impl<A: ToStr> ~[A]: ToStr {
} }
} }
impl<A: ToStr> @A: ToStr { impl<A: ToStr> ToStr for @A {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { ~"@" + (**self).to_str() } pure fn to_str(&self) -> ~str { ~"@" + (**self).to_str() }
} }
impl<A: ToStr> ~A: ToStr { impl<A: ToStr> ToStr for ~A {
#[inline(always)] #[inline(always)]
pure fn to_str(&self) -> ~str { ~"~" + (**self).to_str() } pure fn to_str(&self) -> ~str { ~"~" + (**self).to_str() }
} }

View file

@ -20,7 +20,7 @@ pub trait CopyableTuple<T, U> {
pure fn swap() -> (U, T); pure fn swap() -> (U, T);
} }
impl<T: Copy, U: Copy> (T, U): CopyableTuple<T, U> { impl<T: Copy, U: Copy> CopyableTuple<T, U> for (T, U) {
/// Return the first element of self /// Return the first element of self
#[inline(always)] #[inline(always)]
@ -50,7 +50,7 @@ pub trait ImmutableTuple<T, U> {
pure fn second_ref(&self) -> &self/U; pure fn second_ref(&self) -> &self/U;
} }
impl<T, U> (T, U): ImmutableTuple<T, U> { impl<T, U> ImmutableTuple<T, U> for (T, U) {
#[inline(always)] #[inline(always)]
pure fn first_ref(&self) -> &self/T { pure fn first_ref(&self) -> &self/T {
match *self { match *self {
@ -70,7 +70,7 @@ pub trait ExtendedTupleOps<A,B> {
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C]; fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C];
} }
impl<A: Copy, B: Copy> (&[A], &[B]): ExtendedTupleOps<A,B> { impl<A: Copy, B: Copy> ExtendedTupleOps<A,B> for (&[A], &[B]) {
#[inline(always)] #[inline(always)]
fn zip(&self) -> ~[(A, B)] { fn zip(&self) -> ~[(A, B)] {
match *self { match *self {
@ -90,7 +90,7 @@ impl<A: Copy, B: Copy> (&[A], &[B]): ExtendedTupleOps<A,B> {
} }
} }
impl<A: Copy, B: Copy> (~[A], ~[B]): ExtendedTupleOps<A,B> { impl<A: Copy, B: Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
#[inline(always)] #[inline(always)]
fn zip(&self) -> ~[(A, B)] { fn zip(&self) -> ~[(A, B)] {
@ -112,7 +112,7 @@ impl<A: Copy, B: Copy> (~[A], ~[B]): ExtendedTupleOps<A,B> {
} }
#[cfg(notest)] #[cfg(notest)]
impl<A: Eq, B: Eq> (A, B) : Eq { impl<A: Eq, B: Eq> Eq for (A, B) {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &(A, B)) -> bool { pure fn eq(&self, other: &(A, B)) -> bool {
match (*self) { match (*self) {
@ -128,7 +128,7 @@ impl<A: Eq, B: Eq> (A, B) : Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl<A: Ord, B: Ord> (A, B) : Ord { impl<A: Ord, B: Ord> Ord for (A, B) {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &(A, B)) -> bool { pure fn lt(&self, other: &(A, B)) -> bool {
match (*self) { match (*self) {
@ -153,7 +153,7 @@ impl<A: Ord, B: Ord> (A, B) : Ord {
} }
#[cfg(notest)] #[cfg(notest)]
impl<A: Eq, B: Eq, C: Eq> (A, B, C) : Eq { impl<A: Eq, B: Eq, C: Eq> Eq for (A, B, C) {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &(A, B, C)) -> bool { pure fn eq(&self, other: &(A, B, C)) -> bool {
match (*self) { match (*self) {
@ -170,7 +170,7 @@ impl<A: Eq, B: Eq, C: Eq> (A, B, C) : Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl<A: Ord, B: Ord, C: Ord> (A, B, C) : Ord { impl<A: Ord, B: Ord, C: Ord> Ord for (A, B, C) {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &(A, B, C)) -> bool { pure fn lt(&self, other: &(A, B, C)) -> bool {
match (*self) { match (*self) {

View file

@ -1559,7 +1559,7 @@ pure fn eq<T: Eq>(a: &[T], b: &[T]) -> bool {
} }
#[cfg(notest)] #[cfg(notest)]
impl<T: Eq> &[T] : Eq { impl<T: Eq> Eq for &[T] {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: & &self/[T]) -> bool { eq((*self), (*other)) } pure fn eq(&self, other: & &self/[T]) -> bool { eq((*self), (*other)) }
#[inline(always)] #[inline(always)]
@ -1568,7 +1568,7 @@ impl<T: Eq> &[T] : Eq {
#[cfg(notest)] #[cfg(notest)]
impl<T: Eq> ~[T] : Eq { impl<T: Eq> Eq for ~[T] {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &~[T]) -> bool { eq((*self), (*other)) } pure fn eq(&self, other: &~[T]) -> bool { eq((*self), (*other)) }
#[inline(always)] #[inline(always)]
@ -1576,7 +1576,7 @@ impl<T: Eq> ~[T] : Eq {
} }
#[cfg(notest)] #[cfg(notest)]
impl<T: Eq> @[T] : Eq { impl<T: Eq> Eq for @[T] {
#[inline(always)] #[inline(always)]
pure fn eq(&self, other: &@[T]) -> bool { eq((*self), (*other)) } pure fn eq(&self, other: &@[T]) -> bool { eq((*self), (*other)) }
#[inline(always)] #[inline(always)]
@ -1605,7 +1605,7 @@ 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 gt<T: Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) }
#[cfg(notest)] #[cfg(notest)]
impl<T: Ord> &[T] : Ord { impl<T: Ord> Ord for &[T] {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: & &self/[T]) -> bool { lt((*self), (*other)) } pure fn lt(&self, other: & &self/[T]) -> bool { lt((*self), (*other)) }
#[inline(always)] #[inline(always)]
@ -1617,7 +1617,7 @@ impl<T: Ord> &[T] : Ord {
} }
#[cfg(notest)] #[cfg(notest)]
impl<T: Ord> ~[T] : Ord { impl<T: Ord> Ord for ~[T] {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &~[T]) -> bool { lt((*self), (*other)) } pure fn lt(&self, other: &~[T]) -> bool { lt((*self), (*other)) }
#[inline(always)] #[inline(always)]
@ -1629,7 +1629,7 @@ impl<T: Ord> ~[T] : Ord {
} }
#[cfg(notest)] #[cfg(notest)]
impl<T: Ord> @[T] : Ord { impl<T: Ord> Ord for @[T] {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &@[T]) -> bool { lt((*self), (*other)) } pure fn lt(&self, other: &@[T]) -> bool { lt((*self), (*other)) }
#[inline(always)] #[inline(always)]
@ -1646,7 +1646,7 @@ pub mod traits {
use ops::Add; use ops::Add;
use vec::append; use vec::append;
impl<T: Copy> ~[T] : Add<&[const T],~[T]> { impl<T: Copy> Add<&[const T],~[T]> for ~[T] {
#[inline(always)] #[inline(always)]
pure fn add(&self, rhs: & &self/[const T]) -> ~[T] { pure fn add(&self, rhs: & &self/[const T]) -> ~[T] {
append(copy *self, (*rhs)) append(copy *self, (*rhs))
@ -1654,7 +1654,7 @@ pub mod traits {
} }
} }
impl<T> &[const T]: Container { impl<T> Container for &[const T] {
/// Returns true if a vector contains no elements /// Returns true if a vector contains no elements
#[inline] #[inline]
pure fn is_empty(&self) -> bool { is_empty(*self) } pure fn is_empty(&self) -> bool { is_empty(*self) }
@ -1673,7 +1673,7 @@ pub trait CopyableVector<T> {
} }
/// Extension methods for vectors /// Extension methods for vectors
impl<T: Copy> &[const T]: CopyableVector<T> { impl<T: Copy> CopyableVector<T> for &[const T] {
/// Returns the first element of a vector /// Returns the first element of a vector
#[inline] #[inline]
pure fn head(&self) -> T { head(*self) } pure fn head(&self) -> T { head(*self) }
@ -1709,7 +1709,7 @@ pub trait ImmutableVector<T> {
} }
/// Extension methods for vectors /// Extension methods for vectors
impl<T> &[T]: ImmutableVector<T> { impl<T> ImmutableVector<T> for &[T] {
/// Return a slice that points into another slice. /// Return a slice that points into another slice.
#[inline] #[inline]
pure fn view(&self, start: uint, end: uint) -> &self/[T] { pure fn view(&self, start: uint, end: uint) -> &self/[T] {
@ -1780,7 +1780,7 @@ pub trait ImmutableEqVector<T: Eq> {
pure fn rposition_elem(&self, t: &T) -> Option<uint>; pure fn rposition_elem(&self, t: &T) -> Option<uint>;
} }
impl<T: Eq> &[T]: ImmutableEqVector<T> { impl<T: Eq> ImmutableEqVector<T> for &[T] {
/** /**
* Find the first index matching some predicate * Find the first index matching some predicate
* *
@ -1825,7 +1825,7 @@ pub trait ImmutableCopyableVector<T> {
} }
/// Extension methods for vectors /// Extension methods for vectors
impl<T: Copy> &[T]: ImmutableCopyableVector<T> { impl<T: Copy> ImmutableCopyableVector<T> for &[T] {
/** /**
* Construct a new vector from the elements of a vector for which some * Construct a new vector from the elements of a vector for which some
* predicate holds. * predicate holds.
@ -1876,7 +1876,7 @@ pub trait OwnedVector<T> {
fn partition(self, f: pure fn(&T) -> bool) -> (~[T], ~[T]); fn partition(self, f: pure fn(&T) -> bool) -> (~[T], ~[T]);
} }
impl<T> ~[T]: OwnedVector<T> { impl<T> OwnedVector<T> for ~[T] {
#[inline] #[inline]
fn push(&mut self, t: T) { fn push(&mut self, t: T) {
push(self, t); push(self, t);
@ -1947,7 +1947,7 @@ impl<T> ~[T]: OwnedVector<T> {
} }
} }
impl<T> ~[T]: Mutable { impl<T> Mutable for ~[T] {
/// Clear the vector, removing all values. /// Clear the vector, removing all values.
fn clear(&mut self) { self.truncate(0) } fn clear(&mut self) { self.truncate(0) }
} }
@ -1959,7 +1959,7 @@ pub trait OwnedCopyableVector<T: Copy> {
fn grow_set(&mut self, index: uint, initval: &T, val: T); fn grow_set(&mut self, index: uint, initval: &T, val: T);
} }
impl<T: Copy> ~[T]: OwnedCopyableVector<T> { impl<T: Copy> OwnedCopyableVector<T> for ~[T] {
#[inline] #[inline]
fn push_all(&mut self, rhs: &[const T]) { fn push_all(&mut self, rhs: &[const T]) {
push_all(self, rhs); push_all(self, rhs);
@ -1985,7 +1985,7 @@ trait OwnedEqVector<T: Eq> {
fn dedup(&mut self); fn dedup(&mut self);
} }
impl<T: Eq> ~[T]: OwnedEqVector<T> { impl<T: Eq> OwnedEqVector<T> for ~[T] {
#[inline] #[inline]
fn dedup(&mut self) { fn dedup(&mut self) {
dedup(self) dedup(self)
@ -2218,7 +2218,7 @@ pub mod bytes {
// This cannot be used with iter-trait.rs because of the region pointer // This cannot be used with iter-trait.rs because of the region pointer
// required in the slice. // required in the slice.
impl<A> &[A]: iter::BaseIter<A> { impl<A> iter::BaseIter<A> for &[A] {
pub pure fn each(&self, blk: fn(v: &A) -> bool) { pub pure fn each(&self, blk: fn(v: &A) -> bool) {
// FIXME(#2263)---should be able to call each(self, blk) // FIXME(#2263)---should be able to call each(self, blk)
for each(*self) |e| { for each(*self) |e| {
@ -2231,7 +2231,7 @@ impl<A> &[A]: iter::BaseIter<A> {
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A> ~[A]: iter::BaseIter<A> { impl<A> iter::BaseIter<A> for ~[A] {
pub pure fn each(&self, blk: fn(v: &A) -> bool) { pub pure fn each(&self, blk: fn(v: &A) -> bool) {
// FIXME(#2263)---should be able to call each(self, blk) // FIXME(#2263)---should be able to call each(self, blk)
for each(*self) |e| { for each(*self) |e| {
@ -2244,7 +2244,7 @@ impl<A> ~[A]: iter::BaseIter<A> {
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A> @[A]: iter::BaseIter<A> { impl<A> iter::BaseIter<A> for @[A] {
pub pure fn each(&self, blk: fn(v: &A) -> bool) { pub pure fn each(&self, blk: fn(v: &A) -> bool) {
// FIXME(#2263)---should be able to call each(self, blk) // FIXME(#2263)---should be able to call each(self, blk)
for each(*self) |e| { for each(*self) |e| {
@ -2256,7 +2256,7 @@ impl<A> @[A]: iter::BaseIter<A> {
pure fn size_hint(&self) -> Option<uint> { Some(len(*self)) } pure fn size_hint(&self) -> Option<uint> { Some(len(*self)) }
} }
impl<A> &[A]: iter::ExtendedIter<A> { impl<A> iter::ExtendedIter<A> for &[A] {
pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
iter::eachi(self, blk) iter::eachi(self, blk)
} }
@ -2282,7 +2282,7 @@ impl<A> &[A]: iter::ExtendedIter<A> {
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A> ~[A]: iter::ExtendedIter<A> { impl<A> iter::ExtendedIter<A> for ~[A] {
pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
iter::eachi(self, blk) iter::eachi(self, blk)
} }
@ -2308,7 +2308,7 @@ impl<A> ~[A]: iter::ExtendedIter<A> {
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A> @[A]: iter::ExtendedIter<A> { impl<A> iter::ExtendedIter<A> for @[A] {
pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
iter::eachi(self, blk) iter::eachi(self, blk)
} }
@ -2333,24 +2333,24 @@ impl<A> @[A]: iter::ExtendedIter<A> {
} }
} }
impl<A: Eq> &[A]: iter::EqIter<A> { impl<A: Eq> iter::EqIter<A> for &[A] {
pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A: Eq> ~[A]: iter::EqIter<A> { impl<A: Eq> iter::EqIter<A> for ~[A] {
pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A: Eq> @[A]: iter::EqIter<A> { impl<A: Eq> iter::EqIter<A> for @[A] {
pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
} }
impl<A: Copy> &[A]: iter::CopyableIter<A> { impl<A: Copy> iter::CopyableIter<A> for &[A] {
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred) iter::filter_to_vec(self, pred)
} }
@ -2361,7 +2361,7 @@ impl<A: Copy> &[A]: iter::CopyableIter<A> {
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A: Copy> ~[A]: iter::CopyableIter<A> { impl<A: Copy> iter::CopyableIter<A> for ~[A] {
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred) iter::filter_to_vec(self, pred)
} }
@ -2372,7 +2372,7 @@ impl<A: Copy> ~[A]: iter::CopyableIter<A> {
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A: Copy> @[A]: iter::CopyableIter<A> { impl<A: Copy> iter::CopyableIter<A> for @[A] {
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred) iter::filter_to_vec(self, pred)
} }
@ -2382,24 +2382,24 @@ impl<A: Copy> @[A]: iter::CopyableIter<A> {
} }
} }
impl<A: Copy Ord> &[A]: iter::CopyableOrderedIter<A> { impl<A: Copy Ord> iter::CopyableOrderedIter<A> for &[A] {
pure fn min(&self) -> A { iter::min(self) } pure fn min(&self) -> A { iter::min(self) }
pure fn max(&self) -> A { iter::max(self) } pure fn max(&self) -> A { iter::max(self) }
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A: Copy Ord> ~[A]: iter::CopyableOrderedIter<A> { impl<A: Copy Ord> iter::CopyableOrderedIter<A> for ~[A] {
pure fn min(&self) -> A { iter::min(self) } pure fn min(&self) -> A { iter::min(self) }
pure fn max(&self) -> A { iter::max(self) } pure fn max(&self) -> A { iter::max(self) }
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A: Copy Ord> @[A]: iter::CopyableOrderedIter<A> { impl<A: Copy Ord> iter::CopyableOrderedIter<A> for @[A] {
pure fn min(&self) -> A { iter::min(self) } pure fn min(&self) -> A { iter::min(self) }
pure fn max(&self) -> A { iter::max(self) } pure fn max(&self) -> A { iter::max(self) }
} }
impl<A:Copy> &[A] : iter::CopyableNonstrictIter<A> { impl<A:Copy> iter::CopyableNonstrictIter<A> for &[A] {
pure fn each_val(&const self, f: fn(A) -> bool) { pure fn each_val(&const self, f: fn(A) -> bool) {
let mut i = 0; let mut i = 0;
while i < self.len() { while i < self.len() {
@ -2410,7 +2410,7 @@ impl<A:Copy> &[A] : iter::CopyableNonstrictIter<A> {
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A:Copy> ~[A] : iter::CopyableNonstrictIter<A> { impl<A:Copy> iter::CopyableNonstrictIter<A> for ~[A] {
pure fn each_val(&const self, f: fn(A) -> bool) { pure fn each_val(&const self, f: fn(A) -> bool) {
let mut i = 0; let mut i = 0;
while i < self.len() { while i < self.len() {
@ -2421,7 +2421,7 @@ impl<A:Copy> ~[A] : iter::CopyableNonstrictIter<A> {
} }
// FIXME(#4148): This should be redundant // FIXME(#4148): This should be redundant
impl<A:Copy> @[A] : iter::CopyableNonstrictIter<A> { impl<A:Copy> iter::CopyableNonstrictIter<A> for @[A] {
pure fn each_val(&const self, f: fn(A) -> bool) { pure fn each_val(&const self, f: fn(A) -> bool) {
let mut i = 0; let mut i = 0;
while i < self.len() { while i < self.len() {

View file

@ -120,7 +120,7 @@ enum Family {
InheritedField // N InheritedField // N
} }
impl Family : cmp::Eq { impl cmp::Eq for Family {
pure fn eq(&self, other: &Family) -> bool { pure fn eq(&self, other: &Family) -> bool {
((*self) as uint) == ((*other) as uint) ((*self) as uint) == ((*other) as uint)
} }

View file

@ -41,7 +41,7 @@ pub fn mk_filesearch(maybe_sysroot: Option<Path>,
type filesearch_impl = {sysroot: Path, type filesearch_impl = {sysroot: Path,
addl_lib_search_paths: ~[Path], addl_lib_search_paths: ~[Path],
target_triple: ~str}; target_triple: ~str};
impl filesearch_impl: FileSearch { impl FileSearch for filesearch_impl {
fn sysroot() -> Path { /*bad*/copy self.sysroot } fn sysroot() -> Path { /*bad*/copy self.sysroot }
fn lib_search_paths() -> ~[Path] { fn lib_search_paths() -> ~[Path] {
let mut paths = /*bad*/copy self.addl_lib_search_paths; let mut paths = /*bad*/copy self.addl_lib_search_paths;

View file

@ -224,19 +224,19 @@ impl extended_decode_ctxt {
} }
} }
impl ast::def_id: tr_intern { impl tr_intern for ast::def_id {
fn tr_intern(xcx: extended_decode_ctxt) -> ast::def_id { fn tr_intern(xcx: extended_decode_ctxt) -> ast::def_id {
xcx.tr_intern_def_id(self) xcx.tr_intern_def_id(self)
} }
} }
impl ast::def_id: tr { impl tr for ast::def_id {
fn tr(xcx: extended_decode_ctxt) -> ast::def_id { fn tr(xcx: extended_decode_ctxt) -> ast::def_id {
xcx.tr_def_id(self) xcx.tr_def_id(self)
} }
} }
impl span: tr { impl tr for span {
fn tr(xcx: extended_decode_ctxt) -> span { fn tr(xcx: extended_decode_ctxt) -> span {
xcx.tr_span(self) xcx.tr_span(self)
} }
@ -246,7 +246,7 @@ trait def_id_encoder_helpers {
fn emit_def_id(did: ast::def_id); fn emit_def_id(did: ast::def_id);
} }
impl<S: serialize::Encoder> S: def_id_encoder_helpers { impl<S: serialize::Encoder> def_id_encoder_helpers for S {
fn emit_def_id(did: ast::def_id) { fn emit_def_id(did: ast::def_id) {
did.encode(&self) did.encode(&self)
} }
@ -256,7 +256,7 @@ trait def_id_decoder_helpers {
fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id; fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id;
} }
impl<D: serialize::Decoder> D: def_id_decoder_helpers { impl<D: serialize::Decoder> def_id_decoder_helpers for D {
fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id { fn read_def_id(xcx: extended_decode_ctxt) -> ast::def_id {
let did: ast::def_id = Decodable::decode(&self); let did: ast::def_id = Decodable::decode(&self);
@ -402,7 +402,7 @@ fn decode_def(xcx: extended_decode_ctxt, doc: ebml::Doc) -> ast::def {
def.tr(xcx) def.tr(xcx)
} }
impl ast::def: tr { impl tr for ast::def {
fn tr(xcx: extended_decode_ctxt) -> ast::def { fn tr(xcx: extended_decode_ctxt) -> ast::def {
match self { match self {
ast::def_fn(did, p) => { ast::def_fn(did.tr(xcx), p) } ast::def_fn(did, p) => { ast::def_fn(did.tr(xcx), p) }
@ -447,7 +447,7 @@ impl ast::def: tr {
// ______________________________________________________________________ // ______________________________________________________________________
// Encoding and decoding of adjustment information // Encoding and decoding of adjustment information
impl ty::AutoAdjustment: tr { impl tr for ty::AutoAdjustment {
fn tr(xcx: extended_decode_ctxt) -> ty::AutoAdjustment { fn tr(xcx: extended_decode_ctxt) -> ty::AutoAdjustment {
ty::AutoAdjustment { ty::AutoAdjustment {
autoderefs: self.autoderefs, autoderefs: self.autoderefs,
@ -456,7 +456,7 @@ impl ty::AutoAdjustment: tr {
} }
} }
impl ty::AutoRef: tr { impl tr for ty::AutoRef {
fn tr(xcx: extended_decode_ctxt) -> ty::AutoRef { fn tr(xcx: extended_decode_ctxt) -> ty::AutoRef {
ty::AutoRef { ty::AutoRef {
kind: self.kind, kind: self.kind,
@ -466,7 +466,7 @@ impl ty::AutoRef: tr {
} }
} }
impl ty::Region: tr { impl tr for ty::Region {
fn tr(xcx: extended_decode_ctxt) -> ty::Region { fn tr(xcx: extended_decode_ctxt) -> ty::Region {
match self { match self {
ty::re_bound(br) => ty::re_bound(br.tr(xcx)), ty::re_bound(br) => ty::re_bound(br.tr(xcx)),
@ -477,7 +477,7 @@ impl ty::Region: tr {
} }
} }
impl ty::bound_region: tr { impl tr for ty::bound_region {
fn tr(xcx: extended_decode_ctxt) -> ty::bound_region { fn tr(xcx: extended_decode_ctxt) -> ty::bound_region {
match self { match self {
ty::br_anon(_) | ty::br_named(_) | ty::br_self | ty::br_anon(_) | ty::br_named(_) | ty::br_self |
@ -499,14 +499,14 @@ trait ebml_decoder_helper {
fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry; fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry;
} }
impl reader::Decoder: ebml_decoder_helper { impl ebml_decoder_helper for reader::Decoder {
fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry { fn read_freevar_entry(xcx: extended_decode_ctxt) -> freevar_entry {
let fv: freevar_entry = Decodable::decode(&self); let fv: freevar_entry = Decodable::decode(&self);
fv.tr(xcx) fv.tr(xcx)
} }
} }
impl freevar_entry: tr { impl tr for freevar_entry {
fn tr(xcx: extended_decode_ctxt) -> freevar_entry { fn tr(xcx: extended_decode_ctxt) -> freevar_entry {
freevar_entry { freevar_entry {
def: self.def.tr(xcx), def: self.def.tr(xcx),
@ -522,14 +522,14 @@ trait capture_var_helper {
fn read_capture_var(xcx: extended_decode_ctxt) -> moves::CaptureVar; fn read_capture_var(xcx: extended_decode_ctxt) -> moves::CaptureVar;
} }
impl reader::Decoder : capture_var_helper { impl capture_var_helper for reader::Decoder {
fn read_capture_var(xcx: extended_decode_ctxt) -> moves::CaptureVar { fn read_capture_var(xcx: extended_decode_ctxt) -> moves::CaptureVar {
let cvar: moves::CaptureVar = Decodable::decode(&self); let cvar: moves::CaptureVar = Decodable::decode(&self);
cvar.tr(xcx) cvar.tr(xcx)
} }
} }
impl moves::CaptureVar : tr { impl tr for moves::CaptureVar {
fn tr(xcx: extended_decode_ctxt) -> moves::CaptureVar { fn tr(xcx: extended_decode_ctxt) -> moves::CaptureVar {
moves::CaptureVar { moves::CaptureVar {
def: self.def.tr(xcx), def: self.def.tr(xcx),
@ -562,7 +562,7 @@ fn encode_method_map_entry(ecx: @e::encode_ctxt,
} }
} }
impl reader::Decoder: read_method_map_entry_helper { impl read_method_map_entry_helper for reader::Decoder {
fn read_method_map_entry(xcx: extended_decode_ctxt) -> method_map_entry { fn read_method_map_entry(xcx: extended_decode_ctxt) -> method_map_entry {
do self.read_rec { do self.read_rec {
method_map_entry { method_map_entry {
@ -583,7 +583,7 @@ impl reader::Decoder: read_method_map_entry_helper {
} }
} }
impl method_origin: tr { impl tr for method_origin {
fn tr(xcx: extended_decode_ctxt) -> method_origin { fn tr(xcx: extended_decode_ctxt) -> method_origin {
match self { match self {
typeck::method_static(did) => { typeck::method_static(did) => {
@ -673,7 +673,7 @@ trait vtable_decoder_helpers {
fn read_vtable_origin(xcx: extended_decode_ctxt) -> typeck::vtable_origin; fn read_vtable_origin(xcx: extended_decode_ctxt) -> typeck::vtable_origin;
} }
impl reader::Decoder: vtable_decoder_helpers { impl vtable_decoder_helpers for reader::Decoder {
fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res { fn read_vtable_res(xcx: extended_decode_ctxt) -> typeck::vtable_res {
@self.read_to_vec(|| self.read_vtable_origin(xcx) ) @self.read_to_vec(|| self.read_vtable_origin(xcx) )
} }
@ -731,7 +731,7 @@ trait get_ty_str_ctxt {
fn ty_str_ctxt() -> @tyencode::ctxt; fn ty_str_ctxt() -> @tyencode::ctxt;
} }
impl @e::encode_ctxt: get_ty_str_ctxt { impl get_ty_str_ctxt for @e::encode_ctxt {
fn ty_str_ctxt() -> @tyencode::ctxt { fn ty_str_ctxt() -> @tyencode::ctxt {
@tyencode::ctxt {diag: self.tcx.sess.diagnostic(), @tyencode::ctxt {diag: self.tcx.sess.diagnostic(),
ds: e::def_to_str, ds: e::def_to_str,
@ -750,7 +750,7 @@ trait ebml_writer_helpers {
fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty); fn emit_tpbt(ecx: @e::encode_ctxt, tpbt: ty::ty_param_bounds_and_ty);
} }
impl writer::Encoder: ebml_writer_helpers { impl ebml_writer_helpers for writer::Encoder {
fn emit_ty(ecx: @e::encode_ctxt, ty: ty::t) { fn emit_ty(ecx: @e::encode_ctxt, ty: ty::t) {
do self.emit_opaque { do self.emit_opaque {
e::write_type(ecx, self, ty) e::write_type(ecx, self, ty)
@ -803,7 +803,7 @@ trait write_tag_and_id {
fn id(id: ast::node_id); fn id(id: ast::node_id);
} }
impl writer::Encoder: write_tag_and_id { impl write_tag_and_id for writer::Encoder {
fn tag(tag_id: c::astencode_tag, f: fn()) { fn tag(tag_id: c::astencode_tag, f: fn()) {
do self.wr_tag(tag_id as uint) { f() } do self.wr_tag(tag_id as uint) { f() }
} }
@ -981,7 +981,7 @@ trait doc_decoder_helpers {
fn opt_child(tag: c::astencode_tag) -> Option<ebml::Doc>; fn opt_child(tag: c::astencode_tag) -> Option<ebml::Doc>;
} }
impl ebml::Doc: doc_decoder_helpers { impl doc_decoder_helpers for ebml::Doc {
fn as_int() -> int { reader::doc_as_u64(self) as int } fn as_int() -> int { reader::doc_as_u64(self) as int }
fn opt_child(tag: c::astencode_tag) -> Option<ebml::Doc> { fn opt_child(tag: c::astencode_tag) -> Option<ebml::Doc> {
reader::maybe_get_doc(self, tag as uint) reader::maybe_get_doc(self, tag as uint)
@ -1000,7 +1000,7 @@ trait ebml_decoder_decoder_helpers {
did: ast::def_id) -> ast::def_id; did: ast::def_id) -> ast::def_id;
} }
impl reader::Decoder: ebml_decoder_decoder_helpers { impl ebml_decoder_decoder_helpers for reader::Decoder {
fn read_arg(xcx: extended_decode_ctxt) -> ty::arg { fn read_arg(xcx: extended_decode_ctxt) -> ty::arg {
do self.read_opaque |doc| { do self.read_opaque |doc| {
tydecode::parse_arg_data( tydecode::parse_arg_data(
@ -1198,7 +1198,7 @@ trait fake_ext_ctxt {
type fake_session = parse::parse_sess; type fake_session = parse::parse_sess;
#[cfg(test)] #[cfg(test)]
impl fake_session: fake_ext_ctxt { impl fake_ext_ctxt for fake_session {
fn cfg() -> ast::crate_cfg { ~[] } fn cfg() -> ast::crate_cfg { ~[] }
fn parse_sess() -> parse::parse_sess { self } fn parse_sess() -> parse::parse_sess { self }
fn call_site() -> span { fn call_site() -> span {

View file

@ -106,7 +106,7 @@ pub enum level {
allow, warn, deny, forbid allow, warn, deny, forbid
} }
impl level : cmp::Eq { impl cmp::Eq for level {
pure fn eq(&self, other: &level) -> bool { pure fn eq(&self, other: &level) -> bool {
((*self) as uint) == ((*other) as uint) ((*self) as uint) == ((*other) as uint)
} }

View file

@ -141,12 +141,12 @@ pub type last_use_map = HashMap<node_id, @DVec<node_id>>;
enum Variable = uint; enum Variable = uint;
enum LiveNode = uint; enum LiveNode = uint;
impl Variable : cmp::Eq { impl cmp::Eq for Variable {
pure fn eq(&self, other: &Variable) -> bool { *(*self) == *(*other) } pure fn eq(&self, other: &Variable) -> bool { *(*self) == *(*other) }
pure fn ne(&self, other: &Variable) -> bool { *(*self) != *(*other) } pure fn ne(&self, other: &Variable) -> bool { *(*self) != *(*other) }
} }
impl LiveNode : cmp::Eq { impl cmp::Eq for LiveNode {
pure fn eq(&self, other: &LiveNode) -> bool { *(*self) == *(*other) } pure fn eq(&self, other: &LiveNode) -> bool { *(*self) == *(*other) }
pure fn ne(&self, other: &LiveNode) -> bool { *(*self) != *(*other) } pure fn ne(&self, other: &LiveNode) -> bool { *(*self) != *(*other) }
} }
@ -158,7 +158,7 @@ enum LiveNodeKind {
ExitNode ExitNode
} }
impl LiveNodeKind : cmp::Eq { impl cmp::Eq for LiveNodeKind {
pure fn eq(&self, other: &LiveNodeKind) -> bool { pure fn eq(&self, other: &LiveNodeKind) -> bool {
match (*self) { match (*self) {
FreeVarNode(e0a) => { FreeVarNode(e0a) => {
@ -224,11 +224,11 @@ pub fn check_crate(tcx: ty::ctxt,
return last_use_map; return last_use_map;
} }
impl LiveNode: to_str::ToStr { impl to_str::ToStr for LiveNode {
pure fn to_str(&self) -> ~str { fmt!("ln(%u)", **self) } pure fn to_str(&self) -> ~str { fmt!("ln(%u)", **self) }
} }
impl Variable: to_str::ToStr { impl to_str::ToStr for Variable {
pure fn to_str(&self) -> ~str { fmt!("v(%u)", **self) } pure fn to_str(&self) -> ~str { fmt!("v(%u)", **self) }
} }

View file

@ -179,7 +179,7 @@ pub impl FnType {
enum LLVM_ABIInfo { LLVM_ABIInfo } enum LLVM_ABIInfo { LLVM_ABIInfo }
impl LLVM_ABIInfo: ABIInfo { impl ABIInfo for LLVM_ABIInfo {
fn compute_info(&self, fn compute_info(&self,
atys: &[TypeRef], atys: &[TypeRef],
rty: TypeRef, rty: TypeRef,

View file

@ -32,7 +32,7 @@ enum x86_64_reg_class {
memory_class memory_class
} }
impl x86_64_reg_class : cmp::Eq { impl cmp::Eq for x86_64_reg_class {
pure fn eq(&self, other: &x86_64_reg_class) -> bool { pure fn eq(&self, other: &x86_64_reg_class) -> bool {
((*self) as uint) == ((*other) as uint) ((*self) as uint) == ((*other) as uint)
} }
@ -402,7 +402,7 @@ fn x86_64_tys(atys: &[TypeRef],
enum X86_64_ABIInfo { X86_64_ABIInfo } enum X86_64_ABIInfo { X86_64_ABIInfo }
impl X86_64_ABIInfo: ABIInfo { impl ABIInfo for X86_64_ABIInfo {
fn compute_info(&self, fn compute_info(&self,
atys: &[TypeRef], atys: &[TypeRef],
rty: TypeRef, rty: TypeRef,

View file

@ -165,7 +165,7 @@ impl Dest {
} }
} }
impl Dest : cmp::Eq { impl cmp::Eq for Dest {
pure fn eq(&self, other: &Dest) -> bool { pure fn eq(&self, other: &Dest) -> bool {
match ((*self), (*other)) { match ((*self), (*other)) {
(SaveIn(e0a), SaveIn(e0b)) => e0a == e0b, (SaveIn(e0a), SaveIn(e0b)) => e0a == e0b,
@ -1516,7 +1516,7 @@ pub enum cast_kind {
cast_other, cast_other,
} }
impl cast_kind : cmp::Eq { impl cmp::Eq for cast_kind {
pure fn eq(&self, other: &cast_kind) -> bool { pure fn eq(&self, other: &cast_kind) -> bool {
match ((*self), (*other)) { match ((*self), (*other)) {
(cast_pointer, cast_pointer) => true, (cast_pointer, cast_pointer) => true,

View file

@ -111,7 +111,7 @@ pub struct creader_cache_key {
type creader_cache = HashMap<creader_cache_key, t>; type creader_cache = HashMap<creader_cache_key, t>;
impl creader_cache_key : to_bytes::IterBytes { impl to_bytes::IterBytes for creader_cache_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_3(&self.cnum, &self.pos, &self.len, lsb0, f); to_bytes::iter_bytes_3(&self.cnum, &self.pos, &self.len, lsb0, f);
} }
@ -125,7 +125,7 @@ struct intern_key {
// NB: Do not replace this with #[deriving_eq]. The automatically-derived // NB: Do not replace this with #[deriving_eq]. The automatically-derived
// implementation will not recurse through sty and you will get stack // implementation will not recurse through sty and you will get stack
// exhaustion. // exhaustion.
impl intern_key : cmp::Eq { impl cmp::Eq for intern_key {
pure fn eq(&self, other: &intern_key) -> bool { pure fn eq(&self, other: &intern_key) -> bool {
unsafe { unsafe {
*self.sty == *other.sty && self.o_def_id == other.o_def_id *self.sty == *other.sty && self.o_def_id == other.o_def_id
@ -136,7 +136,7 @@ impl intern_key : cmp::Eq {
} }
} }
impl intern_key : to_bytes::IterBytes { impl to_bytes::IterBytes for intern_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
unsafe { unsafe {
to_bytes::iter_bytes_2(&*self.sty, &self.o_def_id, lsb0, f); to_bytes::iter_bytes_2(&*self.sty, &self.o_def_id, lsb0, f);
@ -155,7 +155,7 @@ pub type opt_region_variance = Option<region_variance>;
#[auto_decode] #[auto_decode]
pub enum region_variance { rv_covariant, rv_invariant, rv_contravariant } pub enum region_variance { rv_covariant, rv_invariant, rv_contravariant }
impl region_variance : cmp::Eq { impl cmp::Eq for region_variance {
pure fn eq(&self, other: &region_variance) -> bool { pure fn eq(&self, other: &region_variance) -> bool {
match ((*self), (*other)) { match ((*self), (*other)) {
(rv_covariant, rv_covariant) => true, (rv_covariant, rv_covariant) => true,
@ -372,13 +372,13 @@ pub struct FnSig {
output: t output: t
} }
impl BareFnTy : to_bytes::IterBytes { impl to_bytes::IterBytes for BareFnTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_3(&self.purity, &self.abi, &self.sig, lsb0, f) to_bytes::iter_bytes_3(&self.purity, &self.abi, &self.sig, lsb0, f)
} }
} }
impl ClosureTy : to_bytes::IterBytes { impl to_bytes::IterBytes for ClosureTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_5(&self.purity, &self.sigil, &self.onceness, to_bytes::iter_bytes_5(&self.purity, &self.sigil, &self.onceness,
&self.region, &self.sig, lsb0, f) &self.region, &self.sig, lsb0, f)
@ -391,7 +391,7 @@ pub struct param_ty {
def_id: def_id def_id: def_id
} }
impl param_ty : to_bytes::IterBytes { impl to_bytes::IterBytes for param_ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.idx, &self.def_id, lsb0, f) to_bytes::iter_bytes_2(&self.idx, &self.def_id, lsb0, f)
} }
@ -597,7 +597,7 @@ pub enum InferTy {
FloatVar(FloatVid) FloatVar(FloatVid)
} }
impl InferTy : to_bytes::IterBytes { impl to_bytes::IterBytes for InferTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
TyVar(ref tv) => to_bytes::iter_bytes_2(&0u8, tv, lsb0, f), TyVar(ref tv) => to_bytes::iter_bytes_2(&0u8, tv, lsb0, f),
@ -614,7 +614,7 @@ pub enum InferRegion {
ReSkolemized(uint, bound_region) ReSkolemized(uint, bound_region)
} }
impl InferRegion : to_bytes::IterBytes { impl to_bytes::IterBytes for InferRegion {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
ReVar(ref rv) => to_bytes::iter_bytes_2(&0u8, rv, lsb0, f), ReVar(ref rv) => to_bytes::iter_bytes_2(&0u8, rv, lsb0, f),
@ -623,7 +623,7 @@ impl InferRegion : to_bytes::IterBytes {
} }
} }
impl InferRegion : cmp::Eq { impl cmp::Eq for InferRegion {
pure fn eq(&self, other: &InferRegion) -> bool { pure fn eq(&self, other: &InferRegion) -> bool {
match ((*self), *other) { match ((*self), *other) {
(ReVar(rva), ReVar(rvb)) => { (ReVar(rva), ReVar(rvb)) => {
@ -640,7 +640,7 @@ impl InferRegion : cmp::Eq {
} }
} }
impl param_bound : to_bytes::IterBytes { impl to_bytes::IterBytes for param_bound {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
bound_copy => 0u8.iter_bytes(lsb0, f), bound_copy => 0u8.iter_bytes(lsb0, f),
@ -1817,19 +1817,19 @@ pub impl TypeContents {
} }
} }
impl TypeContents : ops::Add<TypeContents,TypeContents> { impl ops::Add<TypeContents,TypeContents> for TypeContents {
pure fn add(&self, other: &TypeContents) -> TypeContents { pure fn add(&self, other: &TypeContents) -> TypeContents {
TypeContents {bits: self.bits | other.bits} TypeContents {bits: self.bits | other.bits}
} }
} }
impl TypeContents : ops::Sub<TypeContents,TypeContents> { impl ops::Sub<TypeContents,TypeContents> for TypeContents {
pure fn sub(&self, other: &TypeContents) -> TypeContents { pure fn sub(&self, other: &TypeContents) -> TypeContents {
TypeContents {bits: self.bits & !other.bits} TypeContents {bits: self.bits & !other.bits}
} }
} }
impl TypeContents : ToStr { impl ToStr for TypeContents {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
fmt!("TypeContents(%s)", u32::to_str_radix(self.bits, 2)) fmt!("TypeContents(%s)", u32::to_str_radix(self.bits, 2))
} }
@ -2586,7 +2586,7 @@ pub fn index_sty(cx: ctxt, sty: &sty) -> Option<mt> {
} }
} }
impl bound_region : to_bytes::IterBytes { impl to_bytes::IterBytes for bound_region {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
ty::br_self => 0u8.iter_bytes(lsb0, f), ty::br_self => 0u8.iter_bytes(lsb0, f),
@ -2606,7 +2606,7 @@ impl bound_region : to_bytes::IterBytes {
} }
} }
impl Region : to_bytes::IterBytes { impl to_bytes::IterBytes for Region {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
re_bound(ref br) => re_bound(ref br) =>
@ -2626,7 +2626,7 @@ impl Region : to_bytes::IterBytes {
} }
} }
impl vstore : to_bytes::IterBytes { impl to_bytes::IterBytes for vstore {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
vstore_fixed(ref u) => vstore_fixed(ref u) =>
@ -2641,7 +2641,7 @@ impl vstore : to_bytes::IterBytes {
} }
} }
impl substs : to_bytes::IterBytes { impl to_bytes::IterBytes for substs {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_3(&self.self_r, to_bytes::iter_bytes_3(&self.self_r,
&self.self_ty, &self.self_ty,
@ -2649,28 +2649,28 @@ impl substs : to_bytes::IterBytes {
} }
} }
impl mt : to_bytes::IterBytes { impl to_bytes::IterBytes for mt {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.ty, to_bytes::iter_bytes_2(&self.ty,
&self.mutbl, lsb0, f) &self.mutbl, lsb0, f)
} }
} }
impl field : to_bytes::IterBytes { impl to_bytes::IterBytes for field {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.ident, to_bytes::iter_bytes_2(&self.ident,
&self.mt, lsb0, f) &self.mt, lsb0, f)
} }
} }
impl arg : to_bytes::IterBytes { impl to_bytes::IterBytes for arg {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.mode, to_bytes::iter_bytes_2(&self.mode,
&self.ty, lsb0, f) &self.ty, lsb0, f)
} }
} }
impl FnSig : to_bytes::IterBytes { impl to_bytes::IterBytes for FnSig {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.inputs, to_bytes::iter_bytes_2(&self.inputs,
&self.output, &self.output,
@ -2678,7 +2678,7 @@ impl FnSig : to_bytes::IterBytes {
} }
} }
impl sty : to_bytes::IterBytes { impl to_bytes::IterBytes for sty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
ty_nil => 0u8.iter_bytes(lsb0, f), ty_nil => 0u8.iter_bytes(lsb0, f),
@ -4383,14 +4383,14 @@ pub fn get_impl_id(tcx: ctxt, trait_id: def_id, self_ty: t) -> def_id {
} }
} }
impl mt : cmp::Eq { impl cmp::Eq for mt {
pure fn eq(&self, other: &mt) -> bool { pure fn eq(&self, other: &mt) -> bool {
(*self).ty == (*other).ty && (*self).mutbl == (*other).mutbl (*self).ty == (*other).ty && (*self).mutbl == (*other).mutbl
} }
pure fn ne(&self, other: &mt) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &mt) -> bool { !(*self).eq(other) }
} }
impl vstore : cmp::Eq { impl cmp::Eq for vstore {
pure fn eq(&self, other: &vstore) -> bool { pure fn eq(&self, other: &vstore) -> bool {
match (*self) { match (*self) {
vstore_fixed(e0a) => { vstore_fixed(e0a) => {
@ -4422,7 +4422,7 @@ impl vstore : cmp::Eq {
pure fn ne(&self, other: &vstore) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &vstore) -> bool { !(*self).eq(other) }
} }
impl Region : cmp::Eq { impl cmp::Eq for Region {
pure fn eq(&self, other: &Region) -> bool { pure fn eq(&self, other: &Region) -> bool {
match (*self) { match (*self) {
re_bound(e0a) => { re_bound(e0a) => {
@ -4460,7 +4460,7 @@ impl Region : cmp::Eq {
pure fn ne(&self, other: &Region) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &Region) -> bool { !(*self).eq(other) }
} }
impl bound_region : cmp::Eq { impl cmp::Eq for bound_region {
pure fn eq(&self, other: &bound_region) -> bool { pure fn eq(&self, other: &bound_region) -> bool {
match (*self) { match (*self) {
br_self => { br_self => {
@ -4498,7 +4498,7 @@ impl bound_region : cmp::Eq {
pure fn ne(&self, other: &bound_region) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &bound_region) -> bool { !(*self).eq(other) }
} }
impl param_bound : cmp::Eq { impl cmp::Eq for param_bound {
pure fn eq(&self, other: &param_bound) -> bool { pure fn eq(&self, other: &param_bound) -> bool {
match (*self) { match (*self) {
bound_copy => { bound_copy => {

View file

@ -490,7 +490,7 @@ trait then {
-> Result<T,ty::type_err>; -> Result<T,ty::type_err>;
} }
impl ures: then { impl then for ures {
fn then<T:Copy>(f: fn() -> Result<T,ty::type_err>) fn then<T:Copy>(f: fn() -> Result<T,ty::type_err>)
-> Result<T,ty::type_err> { -> Result<T,ty::type_err> {
self.chain(|_i| f()) self.chain(|_i| f())
@ -501,7 +501,7 @@ trait ToUres {
fn to_ures() -> ures; fn to_ures() -> ures;
} }
impl<T> cres<T>: ToUres { impl<T> ToUres for cres<T> {
fn to_ures() -> ures { fn to_ures() -> ures {
match self { match self {
Ok(ref _v) => Ok(()), Ok(ref _v) => Ok(()),
@ -514,7 +514,7 @@ trait CresCompare<T> {
fn compare(t: T, f: fn() -> ty::type_err) -> cres<T>; fn compare(t: T, f: fn() -> ty::type_err) -> cres<T>;
} }
impl<T:Copy Eq> cres<T>: CresCompare<T> { impl<T:Copy Eq> CresCompare<T> for cres<T> {
fn compare(t: T, f: fn() -> ty::type_err) -> cres<T> { fn compare(t: T, f: fn() -> ty::type_err) -> cres<T> {
do self.chain |s| { do self.chain |s| {
if s == t { if s == t {

View file

@ -568,7 +568,7 @@ enum Constraint {
ConstrainVarSubReg(RegionVid, Region) ConstrainVarSubReg(RegionVid, Region)
} }
impl Constraint : cmp::Eq { impl cmp::Eq for Constraint {
pure fn eq(&self, other: &Constraint) -> bool { pure fn eq(&self, other: &Constraint) -> bool {
match ((*self), (*other)) { match ((*self), (*other)) {
(ConstrainVarSubVar(v0a, v1a), ConstrainVarSubVar(v0b, v1b)) => { (ConstrainVarSubVar(v0a, v1a), ConstrainVarSubVar(v0b, v1b)) => {
@ -588,7 +588,7 @@ impl Constraint : cmp::Eq {
pure fn ne(&self, other: &Constraint) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &Constraint) -> bool { !(*self).eq(other) }
} }
impl Constraint : to_bytes::IterBytes { impl to_bytes::IterBytes for Constraint {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self { match *self {
ConstrainVarSubVar(ref v0, ref v1) => ConstrainVarSubVar(ref v0, ref v1) =>
@ -608,14 +608,14 @@ struct TwoRegions {
b: Region, b: Region,
} }
impl TwoRegions : cmp::Eq { impl cmp::Eq for TwoRegions {
pure fn eq(&self, other: &TwoRegions) -> bool { pure fn eq(&self, other: &TwoRegions) -> bool {
(*self).a == (*other).a && (*self).b == (*other).b (*self).a == (*other).a && (*self).b == (*other).b
} }
pure fn ne(&self, other: &TwoRegions) -> bool { !(*self).eq(other) } pure fn ne(&self, other: &TwoRegions) -> bool { !(*self).eq(other) }
} }
impl TwoRegions : to_bytes::IterBytes { impl to_bytes::IterBytes for TwoRegions {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.a, &self.b, lsb0, f) to_bytes::iter_bytes_2(&self.a, &self.b, lsb0, f)
} }

View file

@ -279,7 +279,7 @@ trait get_and_find_region {
fn find(br: ty::bound_region) -> Option<ty::Region>; fn find(br: ty::bound_region) -> Option<ty::Region>;
} }
impl isr_alist: get_and_find_region { impl get_and_find_region for isr_alist {
fn get(br: ty::bound_region) -> ty::Region { fn get(br: ty::bound_region) -> ty::Region {
self.find(br).get() self.find(br).get()
} }

View file

@ -59,7 +59,7 @@ pub struct Srv {
ch: SharedChan<Msg> ch: SharedChan<Msg>
} }
impl Srv: Clone { impl Clone for Srv {
fn clone(&self) -> Srv { fn clone(&self) -> Srv {
Srv { Srv {
ch: self.ch.clone() ch: self.ch.clone()

View file

@ -28,7 +28,7 @@ pub enum OutputFormat {
pub PandocHtml pub PandocHtml
} }
impl OutputFormat : cmp::Eq { impl cmp::Eq for OutputFormat {
pure fn eq(&self, other: &OutputFormat) -> bool { pure fn eq(&self, other: &OutputFormat) -> bool {
((*self) as uint) == ((*other) as uint) ((*self) as uint) == ((*other) as uint)
} }
@ -43,7 +43,7 @@ pub enum OutputStyle {
pub DocPerMod pub DocPerMod
} }
impl OutputStyle : cmp::Eq { impl cmp::Eq for OutputStyle {
pure fn eq(&self, other: &OutputStyle) -> bool { pure fn eq(&self, other: &OutputStyle) -> bool {
((*self) as uint) == ((*other) as uint) ((*self) as uint) == ((*other) as uint)
} }

View file

@ -187,7 +187,7 @@ trait TheShunnedHouse {
} }
/// Whatever /// Whatever
impl OmNomNomy: TheShunnedHouse { impl TheShunnedHouse for OmNomNomy {
fn dingy_house(&self, _unkempt_yard: int) { fn dingy_house(&self, _unkempt_yard: int) {
} }

View file

@ -284,7 +284,7 @@ pub trait PageUtils {
fn types(&self) -> ~[TyDoc]; fn types(&self) -> ~[TyDoc];
} }
impl ~[Page]: PageUtils { impl PageUtils for ~[Page] {
fn mods(&self) -> ~[ModDoc] { fn mods(&self) -> ~[ModDoc] {
do vec::filter_mapped(*self) |page| { do vec::filter_mapped(*self) |page| {
@ -363,7 +363,7 @@ pub trait Item {
pure fn item(&self) -> ItemDoc; pure fn item(&self) -> ItemDoc;
} }
impl ItemTag: Item { impl Item for ItemTag {
pure fn item(&self) -> ItemDoc { pure fn item(&self) -> ItemDoc {
match self { match self {
&doc::ModTag(ref doc) => copy doc.item, &doc::ModTag(ref doc) => copy doc.item,
@ -379,31 +379,31 @@ impl ItemTag: Item {
} }
} }
impl SimpleItemDoc: Item { impl Item for SimpleItemDoc {
pure fn item(&self) -> ItemDoc { copy self.item } pure fn item(&self) -> ItemDoc { copy self.item }
} }
impl ModDoc: Item { impl Item for ModDoc {
pure fn item(&self) -> ItemDoc { copy self.item } pure fn item(&self) -> ItemDoc { copy self.item }
} }
impl NmodDoc: Item { impl Item for NmodDoc {
pure fn item(&self) -> ItemDoc { copy self.item } pure fn item(&self) -> ItemDoc { copy self.item }
} }
impl EnumDoc: Item { impl Item for EnumDoc {
pure fn item(&self) -> ItemDoc { copy self.item } pure fn item(&self) -> ItemDoc { copy self.item }
} }
impl TraitDoc: Item { impl Item for TraitDoc {
pure fn item(&self) -> ItemDoc { copy self.item } pure fn item(&self) -> ItemDoc { copy self.item }
} }
impl ImplDoc: Item { impl Item for ImplDoc {
pure fn item(&self) -> ItemDoc { copy self.item } pure fn item(&self) -> ItemDoc { copy self.item }
} }
impl StructDoc: Item { impl Item for StructDoc {
pure fn item(&self) -> ItemDoc { copy self.item } pure fn item(&self) -> ItemDoc { copy self.item }
} }
@ -416,7 +416,7 @@ pub trait ItemUtils {
pure fn sections(&self) -> ~[Section]; pure fn sections(&self) -> ~[Section];
} }
impl<A:Item> A: ItemUtils { impl<A:Item> ItemUtils for A {
pure fn id(&self) -> AstId { pure fn id(&self) -> AstId {
self.item().id self.item().id
} }

View file

@ -35,7 +35,7 @@ pub struct Fold<T> {
fold_struct: FoldStruct<T> fold_struct: FoldStruct<T>
} }
impl<T: Clone> Fold<T>: Clone { impl<T: Clone> Clone for Fold<T> {
fn clone(&self) -> Fold<T> { fn clone(&self) -> Fold<T> {
Fold { Fold {
ctxt: self.ctxt.clone(), ctxt: self.ctxt.clone(),

View file

@ -43,7 +43,7 @@ pub trait WriterUtils {
fn write_done(&self); fn write_done(&self);
} }
impl Writer: WriterUtils { impl WriterUtils for Writer {
fn write_str(&self, str: ~str) { fn write_str(&self, str: ~str) {
(*self)(Write(str)); (*self)(Write(str));
} }

View file

@ -34,7 +34,7 @@ struct Ctxt {
mut path: ~[~str] mut path: ~[~str]
} }
impl Ctxt: Clone { impl Clone for Ctxt {
fn clone(&self) -> Ctxt { fn clone(&self) -> Ctxt {
Ctxt { Ctxt {
srv: self.srv.clone(), srv: self.srv.clone(),

View file

@ -17,6 +17,6 @@ pub struct NominalOp<T> {
op: T op: T
} }
impl<T: Copy> NominalOp<T>: Clone { impl<T: Copy> Clone for NominalOp<T> {
fn clone(&self) -> NominalOp<T> { copy *self } fn clone(&self) -> NominalOp<T> { copy *self }
} }

View file

@ -117,7 +117,7 @@ pub fn unwrap<T: Const Owned>(rc: ARC<T>) -> T {
unsafe { unwrap_shared_mutable_state(move x) } unsafe { unwrap_shared_mutable_state(move x) }
} }
impl<T: Const Owned> ARC<T>: Clone { impl<T: Const Owned> Clone for ARC<T> {
fn clone(&self) -> ARC<T> { fn clone(&self) -> ARC<T> {
clone(self) clone(self)
} }
@ -148,7 +148,7 @@ pub fn mutex_arc_with_condvars<T: Owned>(user_data: T,
MutexARC { x: unsafe { shared_mutable_state(move data) } } MutexARC { x: unsafe { shared_mutable_state(move data) } }
} }
impl<T: Owned> MutexARC<T>: Clone { impl<T: Owned> Clone for MutexARC<T> {
/// Duplicate a mutex-protected ARC, as arc::clone. /// Duplicate a mutex-protected ARC, as arc::clone.
fn clone(&self) -> MutexARC<T> { fn clone(&self) -> MutexARC<T> {
// NB: Cloning the underlying mutex is not necessary. Its reference // NB: Cloning the underlying mutex is not necessary. Its reference
@ -247,7 +247,7 @@ struct PoisonOnFail {
failed: *mut bool, failed: *mut bool,
} }
impl PoisonOnFail : Drop { impl Drop for PoisonOnFail {
fn finalize(&self) { fn finalize(&self) {
unsafe { unsafe {
/* assert !*self.failed; /* assert !*self.failed;

View file

@ -81,7 +81,7 @@ pub struct Arena {
priv mut chunks: @List<Chunk>, priv mut chunks: @List<Chunk>,
} }
impl Arena : Drop { impl Drop for Arena {
fn finalize(&self) { fn finalize(&self) {
unsafe { unsafe {
destroy_chunk(&self.head); destroy_chunk(&self.head);

View file

@ -17,7 +17,7 @@ pub trait ToBase64 {
pure fn to_base64() -> ~str; pure fn to_base64() -> ~str;
} }
impl &[u8]: ToBase64 { impl ToBase64 for &[u8] {
pure fn to_base64() -> ~str { pure fn to_base64() -> ~str {
let chars = str::chars( let chars = str::chars(
~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
@ -70,7 +70,7 @@ impl &[u8]: ToBase64 {
} }
} }
impl &str: ToBase64 { impl ToBase64 for &str {
pure fn to_base64() -> ~str { pure fn to_base64() -> ~str {
str::to_bytes(self).to_base64() str::to_bytes(self).to_base64()
} }
@ -80,7 +80,7 @@ pub trait FromBase64 {
pure fn from_base64() -> ~[u8]; pure fn from_base64() -> ~[u8];
} }
impl ~[u8]: FromBase64 { impl FromBase64 for ~[u8] {
pure fn from_base64() -> ~[u8] { pure fn from_base64() -> ~[u8] {
if self.len() % 4u != 0u { fail!(~"invalid base64 length"); } if self.len() % 4u != 0u { fail!(~"invalid base64 length"); }
@ -142,7 +142,7 @@ impl ~[u8]: FromBase64 {
} }
} }
impl ~str: FromBase64 { impl FromBase64 for ~str {
pure fn from_base64() -> ~[u8] { pure fn from_base64() -> ~[u8] {
str::to_bytes(self).from_base64() str::to_bytes(self).from_base64()
} }

View file

@ -75,29 +75,29 @@ pub struct BigUint {
priv data: ~[BigDigit] priv data: ~[BigDigit]
} }
impl BigUint : Eq { impl Eq for BigUint {
pure fn eq(&self, other: &BigUint) -> bool { self.cmp(other) == 0 } pure fn eq(&self, other: &BigUint) -> bool { self.cmp(other) == 0 }
pure fn ne(&self, other: &BigUint) -> bool { self.cmp(other) != 0 } pure fn ne(&self, other: &BigUint) -> bool { self.cmp(other) != 0 }
} }
impl BigUint : Ord { impl Ord for BigUint {
pure fn lt(&self, other: &BigUint) -> bool { self.cmp(other) < 0 } pure fn lt(&self, other: &BigUint) -> bool { self.cmp(other) < 0 }
pure fn le(&self, other: &BigUint) -> bool { self.cmp(other) <= 0 } pure fn le(&self, other: &BigUint) -> bool { self.cmp(other) <= 0 }
pure fn ge(&self, other: &BigUint) -> bool { self.cmp(other) >= 0 } pure fn ge(&self, other: &BigUint) -> bool { self.cmp(other) >= 0 }
pure fn gt(&self, other: &BigUint) -> bool { self.cmp(other) > 0 } pure fn gt(&self, other: &BigUint) -> bool { self.cmp(other) > 0 }
} }
impl BigUint : ToStr { impl ToStr for BigUint {
pure fn to_str(&self) -> ~str { self.to_str_radix(10) } pure fn to_str(&self) -> ~str { self.to_str_radix(10) }
} }
impl BigUint : from_str::FromStr { impl from_str::FromStr for BigUint {
static pure fn from_str(s: &str) -> Option<BigUint> { static pure fn from_str(s: &str) -> Option<BigUint> {
BigUint::from_str_radix(s, 10) BigUint::from_str_radix(s, 10)
} }
} }
impl BigUint : Shl<uint, BigUint> { impl Shl<uint, BigUint> for BigUint {
pure fn shl(&self, rhs: &uint) -> BigUint { pure fn shl(&self, rhs: &uint) -> BigUint {
let n_unit = *rhs / BigDigit::bits; let n_unit = *rhs / BigDigit::bits;
let n_bits = *rhs % BigDigit::bits; let n_bits = *rhs % BigDigit::bits;
@ -105,7 +105,7 @@ impl BigUint : Shl<uint, BigUint> {
} }
} }
impl BigUint : Shr<uint, BigUint> { impl Shr<uint, BigUint> for BigUint {
pure fn shr(&self, rhs: &uint) -> BigUint { pure fn shr(&self, rhs: &uint) -> BigUint {
let n_unit = *rhs / BigDigit::bits; let n_unit = *rhs / BigDigit::bits;
let n_bits = *rhs % BigDigit::bits; let n_bits = *rhs % BigDigit::bits;
@ -113,15 +113,15 @@ impl BigUint : Shr<uint, BigUint> {
} }
} }
impl BigUint : Zero { impl Zero for BigUint {
static pure fn zero() -> BigUint { BigUint::new(~[]) } static pure fn zero() -> BigUint { BigUint::new(~[]) }
} }
impl BigUint : One { impl One for BigUint {
static pub pure fn one() -> BigUint { BigUint::new(~[1]) } static pub pure fn one() -> BigUint { BigUint::new(~[1]) }
} }
impl BigUint : Add<BigUint, BigUint> { impl Add<BigUint, BigUint> for BigUint {
pure fn add(&self, other: &BigUint) -> BigUint { pure fn add(&self, other: &BigUint) -> BigUint {
let new_len = uint::max(self.data.len(), other.data.len()); let new_len = uint::max(self.data.len(), other.data.len());
@ -140,7 +140,7 @@ impl BigUint : Add<BigUint, BigUint> {
} }
} }
impl BigUint : Sub<BigUint, BigUint> { impl Sub<BigUint, BigUint> for BigUint {
pure fn sub(&self, other: &BigUint) -> BigUint { pure fn sub(&self, other: &BigUint) -> BigUint {
let new_len = uint::max(self.data.len(), other.data.len()); let new_len = uint::max(self.data.len(), other.data.len());
@ -165,7 +165,7 @@ impl BigUint : Sub<BigUint, BigUint> {
} }
} }
impl BigUint : Mul<BigUint, BigUint> { impl Mul<BigUint, BigUint> for BigUint {
pure fn mul(&self, other: &BigUint) -> BigUint { pure fn mul(&self, other: &BigUint) -> BigUint {
if self.is_zero() || other.is_zero() { return Zero::zero(); } if self.is_zero() || other.is_zero() { return Zero::zero(); }
@ -230,25 +230,25 @@ impl BigUint : Mul<BigUint, BigUint> {
} }
} }
impl BigUint : Div<BigUint, BigUint> { impl Div<BigUint, BigUint> for BigUint {
pure fn div(&self, other: &BigUint) -> BigUint { pure fn div(&self, other: &BigUint) -> BigUint {
let (d, _) = self.divmod(other); let (d, _) = self.divmod(other);
return d; return d;
} }
} }
impl BigUint : Modulo<BigUint, BigUint> { impl Modulo<BigUint, BigUint> for BigUint {
pure fn modulo(&self, other: &BigUint) -> BigUint { pure fn modulo(&self, other: &BigUint) -> BigUint {
let (_, m) = self.divmod(other); let (_, m) = self.divmod(other);
return m; return m;
} }
} }
impl BigUint : Neg<BigUint> { impl Neg<BigUint> for BigUint {
pure fn neg(&self) -> BigUint { fail!() } pure fn neg(&self) -> BigUint { fail!() }
} }
impl BigUint : IntConvertible { impl IntConvertible for BigUint {
pure fn to_int(&self) -> int { pure fn to_int(&self) -> int {
uint::min(self.to_uint(), int::max_value as uint) as int uint::min(self.to_uint(), int::max_value as uint) as int
} }
@ -554,12 +554,12 @@ priv pure fn get_radix_base(radix: uint) -> (uint, uint) {
/// A Sign is a BigInt's composing element. /// A Sign is a BigInt's composing element.
pub enum Sign { Minus, Zero, Plus } pub enum Sign { Minus, Zero, Plus }
impl Sign : Eq { impl Eq for Sign {
pure fn eq(&self, other: &Sign) -> bool { self.cmp(other) == 0 } pure fn eq(&self, other: &Sign) -> bool { self.cmp(other) == 0 }
pure fn ne(&self, other: &Sign) -> bool { self.cmp(other) != 0 } pure fn ne(&self, other: &Sign) -> bool { self.cmp(other) != 0 }
} }
impl Sign : Ord { impl Ord for Sign {
pure fn lt(&self, other: &Sign) -> bool { self.cmp(other) < 0 } pure fn lt(&self, other: &Sign) -> bool { self.cmp(other) < 0 }
pure fn le(&self, other: &Sign) -> bool { self.cmp(other) <= 0 } pure fn le(&self, other: &Sign) -> bool { self.cmp(other) <= 0 }
pure fn ge(&self, other: &Sign) -> bool { self.cmp(other) >= 0 } pure fn ge(&self, other: &Sign) -> bool { self.cmp(other) >= 0 }
@ -592,53 +592,53 @@ pub struct BigInt {
priv data: BigUint priv data: BigUint
} }
impl BigInt : Eq { impl Eq for BigInt {
pure fn eq(&self, other: &BigInt) -> bool { self.cmp(other) == 0 } pure fn eq(&self, other: &BigInt) -> bool { self.cmp(other) == 0 }
pure fn ne(&self, other: &BigInt) -> bool { self.cmp(other) != 0 } pure fn ne(&self, other: &BigInt) -> bool { self.cmp(other) != 0 }
} }
impl BigInt : Ord { impl Ord for BigInt {
pure fn lt(&self, other: &BigInt) -> bool { self.cmp(other) < 0 } pure fn lt(&self, other: &BigInt) -> bool { self.cmp(other) < 0 }
pure fn le(&self, other: &BigInt) -> bool { self.cmp(other) <= 0 } pure fn le(&self, other: &BigInt) -> bool { self.cmp(other) <= 0 }
pure fn ge(&self, other: &BigInt) -> bool { self.cmp(other) >= 0 } pure fn ge(&self, other: &BigInt) -> bool { self.cmp(other) >= 0 }
pure fn gt(&self, other: &BigInt) -> bool { self.cmp(other) > 0 } pure fn gt(&self, other: &BigInt) -> bool { self.cmp(other) > 0 }
} }
impl BigInt : ToStr { impl ToStr for BigInt {
pure fn to_str(&self) -> ~str { self.to_str_radix(10) } pure fn to_str(&self) -> ~str { self.to_str_radix(10) }
} }
impl BigInt : from_str::FromStr { impl from_str::FromStr for BigInt {
static pure fn from_str(s: &str) -> Option<BigInt> { static pure fn from_str(s: &str) -> Option<BigInt> {
BigInt::from_str_radix(s, 10) BigInt::from_str_radix(s, 10)
} }
} }
impl BigInt : Shl<uint, BigInt> { impl Shl<uint, BigInt> for BigInt {
pure fn shl(&self, rhs: &uint) -> BigInt { pure fn shl(&self, rhs: &uint) -> BigInt {
BigInt::from_biguint(self.sign, self.data << *rhs) BigInt::from_biguint(self.sign, self.data << *rhs)
} }
} }
impl BigInt : Shr<uint, BigInt> { impl Shr<uint, BigInt> for BigInt {
pure fn shr(&self, rhs: &uint) -> BigInt { pure fn shr(&self, rhs: &uint) -> BigInt {
BigInt::from_biguint(self.sign, self.data >> *rhs) BigInt::from_biguint(self.sign, self.data >> *rhs)
} }
} }
impl BigInt : Zero { impl Zero for BigInt {
static pub pure fn zero() -> BigInt { static pub pure fn zero() -> BigInt {
BigInt::from_biguint(Zero, Zero::zero()) BigInt::from_biguint(Zero, Zero::zero())
} }
} }
impl BigInt : One { impl One for BigInt {
static pub pure fn one() -> BigInt { static pub pure fn one() -> BigInt {
BigInt::from_biguint(Plus, One::one()) BigInt::from_biguint(Plus, One::one())
} }
} }
impl BigInt : Add<BigInt, BigInt> { impl Add<BigInt, BigInt> for BigInt {
pure fn add(&self, other: &BigInt) -> BigInt { pure fn add(&self, other: &BigInt) -> BigInt {
match (self.sign, other.sign) { match (self.sign, other.sign) {
(Zero, _) => copy *other, (Zero, _) => copy *other,
@ -652,7 +652,7 @@ impl BigInt : Add<BigInt, BigInt> {
} }
} }
impl BigInt : Sub<BigInt, BigInt> { impl Sub<BigInt, BigInt> for BigInt {
pure fn sub(&self, other: &BigInt) -> BigInt { pure fn sub(&self, other: &BigInt) -> BigInt {
match (self.sign, other.sign) { match (self.sign, other.sign) {
(Zero, _) => -other, (Zero, _) => -other,
@ -672,7 +672,7 @@ impl BigInt : Sub<BigInt, BigInt> {
} }
} }
impl BigInt : Mul<BigInt, BigInt> { impl Mul<BigInt, BigInt> for BigInt {
pure fn mul(&self, other: &BigInt) -> BigInt { pure fn mul(&self, other: &BigInt) -> BigInt {
match (self.sign, other.sign) { match (self.sign, other.sign) {
(Zero, _) | (_, Zero) => Zero::zero(), (Zero, _) | (_, Zero) => Zero::zero(),
@ -686,27 +686,27 @@ impl BigInt : Mul<BigInt, BigInt> {
} }
} }
impl BigInt : Div<BigInt, BigInt> { impl Div<BigInt, BigInt> for BigInt {
pure fn div(&self, other: &BigInt) -> BigInt { pure fn div(&self, other: &BigInt) -> BigInt {
let (d, _) = self.divmod(other); let (d, _) = self.divmod(other);
return d; return d;
} }
} }
impl BigInt : Modulo<BigInt, BigInt> { impl Modulo<BigInt, BigInt> for BigInt {
pure fn modulo(&self, other: &BigInt) -> BigInt { pure fn modulo(&self, other: &BigInt) -> BigInt {
let (_, m) = self.divmod(other); let (_, m) = self.divmod(other);
return m; return m;
} }
} }
impl BigInt : Neg<BigInt> { impl Neg<BigInt> for BigInt {
pure fn neg(&self) -> BigInt { pure fn neg(&self) -> BigInt {
BigInt::from_biguint(self.sign.neg(), copy self.data) BigInt::from_biguint(self.sign.neg(), copy self.data)
} }
} }
impl BigInt : IntConvertible { impl IntConvertible for BigInt {
pure fn to_int(&self) -> int { pure fn to_int(&self) -> int {
match self.sign { match self.sign {
Plus => uint::min(self.to_uint(), int::max_value as uint) as int, Plus => uint::min(self.to_uint(), int::max_value as uint) as int,

View file

@ -507,7 +507,7 @@ impl Bitv {
} }
impl Bitv: Clone { impl Clone for Bitv {
/// Makes a copy of a bitvector /// Makes a copy of a bitvector
#[inline(always)] #[inline(always)]
fn clone(&self) -> Bitv { fn clone(&self) -> Bitv {
@ -568,7 +568,7 @@ pure fn difference(w0: uint, w1: uint) -> uint { return w0 & !w1; }
pure fn right(_w0: uint, w1: uint) -> uint { return w1; } pure fn right(_w0: uint, w1: uint) -> uint { return w1; }
impl Bitv: ops::Index<uint,bool> { impl ops::Index<uint,bool> for Bitv {
pure fn index(&self, i: uint) -> bool { pure fn index(&self, i: uint) -> bool {
self.get(i) self.get(i)
} }

View file

@ -56,7 +56,7 @@ struct DtorRes {
dtor: Option<fn@()>, dtor: Option<fn@()>,
} }
impl DtorRes : Drop { impl Drop for DtorRes {
fn finalize(&self) { fn finalize(&self) {
match self.dtor { match self.dtor {
option::None => (), option::None => (),

View file

@ -21,7 +21,7 @@ pub trait FuzzyEq<Eps> {
pure fn fuzzy_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool; pure fn fuzzy_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool;
} }
impl float: FuzzyEq<float> { impl FuzzyEq<float> for float {
pure fn fuzzy_eq(&self, other: &float) -> bool { pure fn fuzzy_eq(&self, other: &float) -> bool {
self.fuzzy_eq_eps(other, &FUZZY_EPSILON) self.fuzzy_eq_eps(other, &FUZZY_EPSILON)
} }
@ -31,7 +31,7 @@ impl float: FuzzyEq<float> {
} }
} }
impl f32: FuzzyEq<f32> { impl FuzzyEq<f32> for f32 {
pure fn fuzzy_eq(&self, other: &f32) -> bool { pure fn fuzzy_eq(&self, other: &f32) -> bool {
self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f32)) self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f32))
} }
@ -41,7 +41,7 @@ impl f32: FuzzyEq<f32> {
} }
} }
impl f64: FuzzyEq<f64> { impl FuzzyEq<f64> for f64 {
pure fn fuzzy_eq(&self, other: &f64) -> bool { pure fn fuzzy_eq(&self, other: &f64) -> bool {
self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f64)) self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f64))
} }
@ -70,7 +70,7 @@ mod test_complex{
struct Complex { r: float, i: float } struct Complex { r: float, i: float }
impl Complex: FuzzyEq<float> { impl FuzzyEq<float> for Complex {
pure fn fuzzy_eq(&self, other: &Complex) -> bool { pure fn fuzzy_eq(&self, other: &Complex) -> bool {
self.fuzzy_eq_eps(other, &FUZZY_EPSILON) self.fuzzy_eq_eps(other, &FUZZY_EPSILON)
} }

View file

@ -25,19 +25,19 @@ pub struct DuplexStream<T, U> {
priv port: Port<U>, priv port: Port<U>,
} }
impl<T: Owned, U: Owned> DuplexStream<T, U> : GenericChan<T> { impl<T: Owned, U: Owned> GenericChan<T> for DuplexStream<T, U> {
fn send(x: T) { fn send(x: T) {
self.chan.send(move x) self.chan.send(move x)
} }
} }
impl<T: Owned, U: Owned> DuplexStream<T, U> : GenericSmartChan<T> { impl<T: Owned, U: Owned> GenericSmartChan<T> for DuplexStream<T, U> {
fn try_send(x: T) -> bool { fn try_send(x: T) -> bool {
self.chan.try_send(move x) self.chan.try_send(move x)
} }
} }
impl<T: Owned, U: Owned> DuplexStream<T, U> : GenericPort<U> { impl<T: Owned, U: Owned> GenericPort<U> for DuplexStream<T, U> {
fn recv() -> U { fn recv() -> U {
self.port.recv() self.port.recv()
} }
@ -47,13 +47,13 @@ impl<T: Owned, U: Owned> DuplexStream<T, U> : GenericPort<U> {
} }
} }
impl<T: Owned, U: Owned> DuplexStream<T, U> : Peekable<U> { impl<T: Owned, U: Owned> Peekable<U> for DuplexStream<T, U> {
pure fn peek() -> bool { pure fn peek() -> bool {
self.port.peek() self.port.peek()
} }
} }
impl<T: Owned, U: Owned> DuplexStream<T, U> : Selectable { impl<T: Owned, U: Owned> Selectable for DuplexStream<T, U> {
pure fn header() -> *pipes::PacketHeader { pure fn header() -> *pipes::PacketHeader {
self.port.header() self.port.header()
} }

View file

@ -67,7 +67,7 @@ pub fn create<T: Copy>() -> Deque<T> {
elts: DVec<Cell<T>>, elts: DVec<Cell<T>>,
} }
impl <T: Copy> Repr<T>: Deque<T> { impl<T: Copy> Deque<T> for Repr<T> {
fn size() -> uint { return self.nelts; } fn size() -> uint { return self.nelts; }
fn add_front(t: T) { fn add_front(t: T) {
let oldlo: uint = self.lo; let oldlo: uint = self.lo;

View file

@ -74,7 +74,7 @@ pub mod reader {
// ebml reading // ebml reading
impl Doc: ops::Index<uint,Doc> { impl ops::Index<uint,Doc> for Doc {
pure fn index(&self, tag: uint) -> Doc { pure fn index(&self, tag: uint) -> Doc {
unsafe { unsafe {
get_doc(*self, tag) get_doc(*self, tag)
@ -285,7 +285,7 @@ pub mod reader {
} }
} }
impl Decoder: serialize::Decoder { impl serialize::Decoder for Decoder {
fn read_nil(&self) -> () { () } fn read_nil(&self) -> () { () }
fn read_u64(&self) -> u64 { doc_as_u64(self.next_doc(EsU64)) } fn read_u64(&self) -> u64 { doc_as_u64(self.next_doc(EsU64)) }
@ -577,7 +577,7 @@ pub mod writer {
} }
} }
impl Encoder: ::serialize::Encoder { impl ::serialize::Encoder for Encoder {
fn emit_nil(&self) {} fn emit_nil(&self) {}
fn emit_uint(&self, v: uint) { fn emit_uint(&self, v: uint) {

View file

@ -303,7 +303,7 @@ pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P>: GenericPort<T> {
} }
} }
impl<T,F:Flattener<T>,C:ByteChan> FlatChan<T, F, C>: GenericChan<T> { impl<T,F:Flattener<T>,C:ByteChan> GenericChan<T> for FlatChan<T, F, C> {
fn send(val: T) { fn send(val: T) {
self.byte_chan.send(CONTINUE.to_vec()); self.byte_chan.send(CONTINUE.to_vec());
let bytes = self.flattener.flatten(move val); let bytes = self.flattener.flatten(move val);
@ -474,7 +474,7 @@ pub mod flatteners {
static fn from_writer(w: Writer) -> Self; static fn from_writer(w: Writer) -> Self;
} }
impl json::Decoder: FromReader { impl FromReader for json::Decoder {
static fn from_reader(r: Reader) -> json::Decoder { static fn from_reader(r: Reader) -> json::Decoder {
match json::from_reader(r) { match json::from_reader(r) {
Ok(move json) => { Ok(move json) => {
@ -485,13 +485,13 @@ pub mod flatteners {
} }
} }
impl json::Encoder: FromWriter { impl FromWriter for json::Encoder {
static fn from_writer(w: Writer) -> json::Encoder { static fn from_writer(w: Writer) -> json::Encoder {
json::Encoder(move w) json::Encoder(move w)
} }
} }
impl ebml::reader::Decoder: FromReader { impl FromReader for ebml::reader::Decoder {
static fn from_reader(r: Reader) -> ebml::reader::Decoder { static fn from_reader(r: Reader) -> ebml::reader::Decoder {
let buf = @r.read_whole_stream(); let buf = @r.read_whole_stream();
let doc = ebml::reader::Doc(buf); let doc = ebml::reader::Doc(buf);
@ -499,7 +499,7 @@ pub mod flatteners {
} }
} }
impl ebml::writer::Encoder: FromWriter { impl FromWriter for ebml::writer::Encoder {
static fn from_writer(w: Writer) -> ebml::writer::Encoder { static fn from_writer(w: Writer) -> ebml::writer::Encoder {
ebml::writer::Encoder(move w) ebml::writer::Encoder(move w)
} }

View file

@ -36,7 +36,7 @@ pub struct Future<A> {
// FIXME(#2829) -- futures should not be copyable, because they close // FIXME(#2829) -- futures should not be copyable, because they close
// over fn~'s that have pipes and so forth within! // over fn~'s that have pipes and so forth within!
impl<A> Future<A> : Drop { impl<A> Drop for Future<A> {
fn finalize(&self) {} fn finalize(&self) {}
} }

View file

@ -42,7 +42,7 @@ pub impl BufReader {
} }
} }
impl BufReader: Reader { impl Reader for BufReader {
fn read(&self, bytes: &mut [u8], len: uint) -> uint { fn read(&self, bytes: &mut [u8], len: uint) -> uint {
self.as_bytes_reader(|r| r.read(bytes, len) ) self.as_bytes_reader(|r| r.read(bytes, len) )
} }

View file

@ -949,7 +949,7 @@ pub impl Decoder: serialize::Decoder {
} }
} }
impl Json : Eq { impl Eq for Json {
pure fn eq(&self, other: &Json) -> bool { pure fn eq(&self, other: &Json) -> bool {
match (self) { match (self) {
&Number(f0) => &Number(f0) =>
@ -987,7 +987,7 @@ impl Json : Eq {
} }
/// Test if two json values are less than one another /// Test if two json values are less than one another
impl Json : Ord { impl Ord for Json {
pure fn lt(&self, other: &Json) -> bool { pure fn lt(&self, other: &Json) -> bool {
match (*self) { match (*self) {
Number(f0) => { Number(f0) => {
@ -1063,7 +1063,7 @@ impl Json : Ord {
pure fn gt(&self, other: &Json) -> bool { (*other).lt(&(*self)) } pure fn gt(&self, other: &Json) -> bool { (*other).lt(&(*self)) }
} }
impl Error : Eq { impl Eq for Error {
pure fn eq(&self, other: &Error) -> bool { pure fn eq(&self, other: &Error) -> bool {
(*self).line == other.line && (*self).line == other.line &&
(*self).col == other.col && (*self).col == other.col &&
@ -1074,83 +1074,83 @@ impl Error : Eq {
trait ToJson { fn to_json() -> Json; } trait ToJson { fn to_json() -> Json; }
impl Json: ToJson { impl ToJson for Json {
fn to_json() -> Json { copy self } fn to_json() -> Json { copy self }
} }
impl @Json: ToJson { impl ToJson for @Json {
fn to_json() -> Json { (*self).to_json() } fn to_json() -> Json { (*self).to_json() }
} }
impl int: ToJson { impl ToJson for int {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl i8: ToJson { impl ToJson for i8 {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl i16: ToJson { impl ToJson for i16 {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl i32: ToJson { impl ToJson for i32 {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl i64: ToJson { impl ToJson for i64 {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl uint: ToJson { impl ToJson for uint {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl u8: ToJson { impl ToJson for u8 {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl u16: ToJson { impl ToJson for u16 {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl u32: ToJson { impl ToJson for u32 {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl u64: ToJson { impl ToJson for u64 {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl float: ToJson { impl ToJson for float {
fn to_json() -> Json { Number(self) } fn to_json() -> Json { Number(self) }
} }
impl f32: ToJson { impl ToJson for f32 {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl f64: ToJson { impl ToJson for f64 {
fn to_json() -> Json { Number(self as float) } fn to_json() -> Json { Number(self as float) }
} }
impl (): ToJson { impl ToJson for () {
fn to_json() -> Json { Null } fn to_json() -> Json { Null }
} }
impl bool: ToJson { impl ToJson for bool {
fn to_json() -> Json { Boolean(self) } fn to_json() -> Json { Boolean(self) }
} }
impl ~str: ToJson { impl ToJson for ~str {
fn to_json() -> Json { String(copy self) } fn to_json() -> Json { String(copy self) }
} }
impl @~str: ToJson { impl ToJson for @~str {
fn to_json() -> Json { String(copy *self) } fn to_json() -> Json { String(copy *self) }
} }
impl <A: ToJson, B: ToJson> (A, B): ToJson { impl<A: ToJson, B: ToJson> ToJson for (A, B) {
fn to_json() -> Json { fn to_json() -> Json {
match self { match self {
(ref a, ref b) => { (ref a, ref b) => {
@ -1160,7 +1160,7 @@ impl <A: ToJson, B: ToJson> (A, B): ToJson {
} }
} }
impl <A: ToJson, B: ToJson, C: ToJson> (A, B, C): ToJson { impl<A: ToJson, B: ToJson, C: ToJson> ToJson for (A, B, C) {
fn to_json() -> Json { fn to_json() -> Json {
match self { match self {
(ref a, ref b, ref c) => { (ref a, ref b, ref c) => {
@ -1170,11 +1170,11 @@ impl <A: ToJson, B: ToJson, C: ToJson> (A, B, C): ToJson {
} }
} }
impl <A: ToJson> ~[A]: ToJson { impl<A: ToJson> ToJson for ~[A] {
fn to_json() -> Json { List(self.map(|elt| elt.to_json())) } fn to_json() -> Json { List(self.map(|elt| elt.to_json())) }
} }
impl <A: ToJson Copy> LinearMap<~str, A>: ToJson { impl<A: ToJson Copy> ToJson for LinearMap<~str, A> {
fn to_json() -> Json { fn to_json() -> Json {
let mut d = LinearMap::new(); let mut d = LinearMap::new();
for self.each |&(key, value)| { for self.each |&(key, value)| {
@ -1184,7 +1184,7 @@ impl <A: ToJson Copy> LinearMap<~str, A>: ToJson {
} }
} }
impl <A: ToJson> Option<A>: ToJson { impl<A: ToJson> ToJson for Option<A> {
fn to_json() -> Json { fn to_json() -> Json {
match self { match self {
None => Null, None => Null,
@ -1193,11 +1193,11 @@ impl <A: ToJson> Option<A>: ToJson {
} }
} }
impl Json: to_str::ToStr { impl to_str::ToStr for Json {
pure fn to_str(&self) -> ~str { to_str(self) } pure fn to_str(&self) -> ~str { to_str(self) }
} }
impl Error: to_str::ToStr { impl to_str::ToStr for Error {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
fmt!("%u:%u: %s", self.line, self.col, *self.msg) fmt!("%u:%u: %s", self.line, self.col, *self.msg)
} }

View file

@ -193,7 +193,7 @@ pub mod v4 {
unsafe fn as_u32() -> u32; unsafe fn as_u32() -> u32;
} }
impl Ipv4Rep: AsUnsafeU32 { impl AsUnsafeU32 for Ipv4Rep {
// this is pretty dastardly, i know // this is pretty dastardly, i know
unsafe fn as_u32() -> u32 { unsafe fn as_u32() -> u32 {
*((ptr::addr_of(&self)) as *u32) *((ptr::addr_of(&self)) as *u32)

View file

@ -51,7 +51,7 @@ pub struct TcpSocket {
socket_data: @TcpSocketData, socket_data: @TcpSocketData,
} }
impl TcpSocket : Drop { impl Drop for TcpSocket {
fn finalize(&self) { fn finalize(&self) {
unsafe { unsafe {
tear_down_socket_data(self.socket_data) tear_down_socket_data(self.socket_data)
@ -863,7 +863,7 @@ impl TcpSocket {
} }
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket` /// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
impl TcpSocketBuf: io::Reader { impl io::Reader for TcpSocketBuf {
fn read(&self, buf: &mut [u8], len: uint) -> uint { fn read(&self, buf: &mut [u8], len: uint) -> uint {
if len == 0 { return 0 } if len == 0 { return 0 }
let mut count: uint = 0; let mut count: uint = 0;
@ -963,7 +963,7 @@ impl TcpSocketBuf: io::Reader {
} }
/// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket` /// Implementation of `io::reader` trait for a buffered `net::tcp::tcp_socket`
impl TcpSocketBuf: io::Writer { impl io::Writer for TcpSocketBuf {
pub fn write(&self, data: &[const u8]) { pub fn write(&self, data: &[const u8]) {
unsafe { unsafe {
let socket_data_ptr = let socket_data_ptr =
@ -1264,7 +1264,7 @@ trait ToTcpErr {
fn to_tcp_err() -> TcpErrData; fn to_tcp_err() -> TcpErrData;
} }
impl uv::ll::uv_err_data: ToTcpErr { impl ToTcpErr for uv::ll::uv_err_data {
fn to_tcp_err() -> TcpErrData { fn to_tcp_err() -> TcpErrData {
TcpErrData { err_name: self.err_name, err_msg: self.err_msg } TcpErrData { err_name: self.err_name, err_msg: self.err_msg }
} }

View file

@ -668,7 +668,7 @@ pub pure fn from_str(rawurl: &str) -> Result<Url, ~str> {
Ok(Url::new(scheme, userinfo, host, port, path, query, fragment)) Ok(Url::new(scheme, userinfo, host, port, path, query, fragment))
} }
impl Url: FromStr { impl FromStr for Url {
static pure fn from_str(s: &str) -> Option<Url> { static pure fn from_str(s: &str) -> Option<Url> {
match from_str(s) { match from_str(s) {
Ok(move url) => Some(url), Ok(move url) => Some(url),
@ -718,13 +718,13 @@ pub pure fn to_str(url: &Url) -> ~str {
fmt!("%s:%s%s%s%s", url.scheme, authority, url.path, query, fragment) fmt!("%s:%s%s%s%s", url.scheme, authority, url.path, query, fragment)
} }
impl Url: to_str::ToStr { impl to_str::ToStr for Url {
pub pure fn to_str(&self) -> ~str { pub pure fn to_str(&self) -> ~str {
to_str(self) to_str(self)
} }
} }
impl Url: to_bytes::IterBytes { impl to_bytes::IterBytes for Url {
pure fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
self.to_str().iter_bytes(lsb0, f) self.to_str().iter_bytes(lsb0, f)
} }

View file

@ -156,12 +156,12 @@ pub mod chained {
} }
} }
impl<K: Eq IterBytes Hash, V> T<K, V>: Container { impl<K: Eq IterBytes Hash, V> Container for T<K, V> {
pure fn len(&self) -> uint { self.count } pure fn len(&self) -> uint { self.count }
pure fn is_empty(&self) -> bool { self.count == 0 } pure fn is_empty(&self) -> bool { self.count == 0 }
} }
impl<K: Eq IterBytes Hash, V> T<K, V>: Mutable { impl<K: Eq IterBytes Hash, V> Mutable for T<K, V> {
fn clear(&mut self) { fn clear(&mut self) {
self.count = 0u; self.count = 0u;
self.chains = chains(initial_capacity); self.chains = chains(initial_capacity);
@ -347,7 +347,7 @@ pub mod chained {
} }
} }
impl<K:Eq IterBytes Hash Copy ToStr, V: ToStr Copy> T<K, V>: ToStr { impl<K:Eq IterBytes Hash Copy ToStr, V: ToStr Copy> ToStr for T<K, V> {
pure fn to_str(&self) -> ~str { pure fn to_str(&self) -> ~str {
unsafe { unsafe {
// Meh -- this should be safe // Meh -- this should be safe
@ -356,7 +356,7 @@ pub mod chained {
} }
} }
impl<K:Eq IterBytes Hash Copy, V: Copy> T<K, V>: ops::Index<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 { pure fn index(&self, k: K) -> V {
self.get(&k) self.get(&k)
} }

View file

@ -78,7 +78,7 @@ pub pure fn contains_key<T: Copy>(self: SmallIntMap<T>, key: uint) -> bool {
return !find(self, key).is_none(); return !find(self, key).is_none();
} }
impl<V> SmallIntMap<V>: Container { impl<V> Container for SmallIntMap<V> {
/// Return the number of elements in the map /// Return the number of elements in the map
pure fn len(&self) -> uint { pure fn len(&self) -> uint {
let mut sz = 0u; let mut sz = 0u;
@ -95,7 +95,7 @@ impl<V> SmallIntMap<V>: Container {
pure fn is_empty(&self) -> bool { self.len() == 0 } pure fn is_empty(&self) -> bool { self.len() == 0 }
} }
impl<V> SmallIntMap<V>: Mutable { impl<V> Mutable for SmallIntMap<V> {
fn clear(&mut self) { self.v.set(~[]) } fn clear(&mut self) { self.v.set(~[]) }
} }
@ -162,7 +162,7 @@ impl<V: Copy> SmallIntMap<V> {
} }
} }
impl<V: Copy> SmallIntMap<V>: ops::Index<uint, V> { impl<V: Copy> ops::Index<uint, V> for SmallIntMap<V> {
pure fn index(&self, key: uint) -> V { pure fn index(&self, key: uint) -> V {
unsafe { unsafe {
get(*self, key) get(*self, key)

View file

@ -27,7 +27,7 @@ pub struct PriorityQueue<T> {
priv data: ~[T], priv data: ~[T],
} }
impl <T: Ord> PriorityQueue<T>: BaseIter<T> { impl<T: Ord> BaseIter<T> for PriorityQueue<T> {
/// Visit all values in the underlying vector. /// Visit all values in the underlying vector.
/// ///
/// The values are **not** visited in order. /// The values are **not** visited in order.
@ -35,7 +35,7 @@ impl <T: Ord> PriorityQueue<T>: BaseIter<T> {
pure fn size_hint(&self) -> Option<uint> { self.data.size_hint() } pure fn size_hint(&self) -> Option<uint> { self.data.size_hint() }
} }
impl <T: Ord> PriorityQueue<T>: Container { impl<T: Ord> Container for PriorityQueue<T> {
/// Returns the length of the queue /// Returns the length of the queue
pure fn len(&self) -> uint { self.data.len() } pure fn len(&self) -> uint { self.data.len() }
@ -43,7 +43,7 @@ impl <T: Ord> PriorityQueue<T>: Container {
pure fn is_empty(&self) -> bool { self.data.is_empty() } pure fn is_empty(&self) -> bool { self.data.is_empty() }
} }
impl <T: Ord> PriorityQueue<T>: Mutable { impl<T: Ord> Mutable for PriorityQueue<T> {
/// Drop all items from the queue /// Drop all items from the queue
fn clear(&mut self) { self.data.truncate(0) } fn clear(&mut self) { self.data.truncate(0) }
} }

View file

@ -228,7 +228,7 @@ pub fn sha1() -> Sha1 {
process_msg_block(st); process_msg_block(st);
} }
impl Sha1State: Sha1 { impl Sha1 for Sha1State {
fn reset(&mut self) { fn reset(&mut self) {
assert (vec::len(self.h) == digest_buf_len); assert (vec::len(self.h) == digest_buf_len);
self.len_low = 0u32; self.len_low = 0u32;

View file

@ -22,7 +22,7 @@ pub struct SmallIntMap<T> {
priv v: ~[Option<T>], priv v: ~[Option<T>],
} }
impl<V> SmallIntMap<V>: BaseIter<(uint, &V)> { impl<V> BaseIter<(uint, &V)> for SmallIntMap<V> {
/// Visit all key-value pairs in order /// Visit all key-value pairs in order
pure fn each(&self, it: fn(&(uint, &self/V)) -> bool) { pure fn each(&self, it: fn(&(uint, &self/V)) -> bool) {
for uint::range(0, self.v.len()) |i| { for uint::range(0, self.v.len()) |i| {
@ -36,7 +36,7 @@ impl<V> SmallIntMap<V>: BaseIter<(uint, &V)> {
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
} }
impl<V> SmallIntMap<V>: ReverseIter<(uint, &V)> { impl<V> ReverseIter<(uint, &V)> for SmallIntMap<V> {
/// Visit all key-value pairs in reverse order /// Visit all key-value pairs in reverse order
pure fn each_reverse(&self, it: fn(&(uint, &self/V)) -> bool) { pure fn each_reverse(&self, it: fn(&(uint, &self/V)) -> bool) {
for uint::range_rev(self.v.len(), 0) |i| { for uint::range_rev(self.v.len(), 0) |i| {
@ -48,7 +48,7 @@ impl<V> SmallIntMap<V>: ReverseIter<(uint, &V)> {
} }
} }
impl<V> SmallIntMap<V>: Container { impl<V> Container for SmallIntMap<V> {
/// Return the number of elements in the map /// Return the number of elements in the map
pure fn len(&self) -> uint { pure fn len(&self) -> uint {
let mut sz = 0; let mut sz = 0;
@ -64,12 +64,12 @@ impl<V> SmallIntMap<V>: Container {
pure fn is_empty(&self) -> bool { self.len() == 0 } pure fn is_empty(&self) -> bool { self.len() == 0 }
} }
impl<V> SmallIntMap<V>: Mutable { impl<V> Mutable for SmallIntMap<V> {
/// Clear the map, removing all key-value pairs. /// Clear the map, removing all key-value pairs.
fn clear(&mut self) { self.v.clear() } fn clear(&mut self) { self.v.clear() }
} }
impl<V> SmallIntMap<V>: Map<uint, V> { impl<V> Map<uint, V> for SmallIntMap<V> {
/// Return true if the map contains a value for the specified key /// Return true if the map contains a value for the specified key
pure fn contains_key(&self, key: &uint) -> bool { pure fn contains_key(&self, key: &uint) -> bool {
self.find(key).is_some() self.find(key).is_some()

View file

@ -169,7 +169,7 @@ pub trait Sort {
fn qsort(self); fn qsort(self);
} }
impl<T: Copy Ord Eq> &mut [T] : Sort { impl<T: Copy Ord Eq> Sort for &mut [T] {
fn qsort(self) { quick_sort3(self); } fn qsort(self) { quick_sort3(self); }
} }
@ -908,7 +908,7 @@ mod test_tim_sort {
val: float, val: float,
} }
impl CVal: Ord { impl Ord for CVal {
pure fn lt(&self, other: &CVal) -> bool { pure fn lt(&self, other: &CVal) -> bool {
unsafe { unsafe {
let rng = rand::Rng(); let rng = rand::Rng();
@ -973,7 +973,7 @@ mod test_tim_sort {
struct DVal { val: uint } struct DVal { val: uint }
impl DVal: Ord { impl Ord for DVal {
pure fn lt(&self, _x: &DVal) -> bool { true } pure fn lt(&self, _x: &DVal) -> bool { true }
pure fn le(&self, _x: &DVal) -> bool { true } pure fn le(&self, _x: &DVal) -> bool { true }
pure fn gt(&self, _x: &DVal) -> bool { true } pure fn gt(&self, _x: &DVal) -> bool { true }
@ -1182,7 +1182,7 @@ mod big_tests {
} }
impl LVal : Drop { impl Drop for LVal {
fn finalize(&self) { fn finalize(&self) {
let x = unsafe { task::local_data::local_data_get(self.key) }; let x = unsafe { task::local_data::local_data_get(self.key) };
match x { match x {
@ -1196,7 +1196,7 @@ mod big_tests {
} }
} }
impl LVal: Ord { impl Ord for LVal {
pure fn lt(&self, other: &a/LVal/&self) -> bool { pure fn lt(&self, other: &a/LVal/&self) -> bool {
(*self).val < other.val (*self).val < other.val
} }

View file

@ -30,7 +30,7 @@ pub trait Stats {
fn median_abs_dev_pct(self) -> f64; fn median_abs_dev_pct(self) -> f64;
} }
impl &[f64] : Stats { impl Stats for &[f64] {
fn sum(self) -> f64 { fn sum(self) -> f64 {
vec::foldl(0.0, self, |p,q| p + *q) vec::foldl(0.0, self, |p,q| p + *q)
} }

View file

@ -167,7 +167,7 @@ type SemRelease = SemReleaseGeneric<()>;
type SemAndSignalRelease = SemReleaseGeneric<~[Waitqueue]>; type SemAndSignalRelease = SemReleaseGeneric<~[Waitqueue]>;
struct SemReleaseGeneric<Q> { sem: &Sem<Q> } struct SemReleaseGeneric<Q> { sem: &Sem<Q> }
impl<Q: Owned> SemReleaseGeneric<Q> : Drop { impl<Q: Owned> Drop for SemReleaseGeneric<Q> {
fn finalize(&self) { fn finalize(&self) {
self.sem.release(); self.sem.release();
} }
@ -189,7 +189,7 @@ fn SemAndSignalRelease(sem: &r/Sem<~[Waitqueue]>)
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling. /// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
pub struct Condvar { priv sem: &Sem<~[Waitqueue]> } pub struct Condvar { priv sem: &Sem<~[Waitqueue]> }
impl Condvar : Drop { fn finalize(&self) {} } impl Drop for Condvar { fn finalize(&self) {} }
impl &Condvar { impl &Condvar {
/** /**
@ -260,7 +260,7 @@ impl &Condvar {
sem: &Sem<~[Waitqueue]>, sem: &Sem<~[Waitqueue]>,
} }
impl SemAndSignalReacquire : Drop { impl Drop for SemAndSignalReacquire {
fn finalize(&self) { fn finalize(&self) {
unsafe { unsafe {
// Needs to succeed, instead of itself dying. // Needs to succeed, instead of itself dying.
@ -362,7 +362,7 @@ pub fn semaphore(count: int) -> Semaphore {
Semaphore { sem: new_sem(count, ()) } Semaphore { sem: new_sem(count, ()) }
} }
impl Semaphore: Clone { impl Clone for Semaphore {
/// Create a new handle to the semaphore. /// Create a new handle to the semaphore.
fn clone(&self) -> Semaphore { fn clone(&self) -> Semaphore {
Semaphore { sem: Sem((*self.sem).clone()) } Semaphore { sem: Sem((*self.sem).clone()) }
@ -412,7 +412,7 @@ pub fn mutex_with_condvars(num_condvars: uint) -> Mutex {
Mutex { sem: new_sem_and_signal(1, num_condvars) } Mutex { sem: new_sem_and_signal(1, num_condvars) }
} }
impl Mutex: Clone { impl Clone for Mutex {
/// Create a new handle to the mutex. /// Create a new handle to the mutex.
fn clone(&self) -> Mutex { Mutex { sem: Sem((*self.sem).clone()) } } fn clone(&self) -> Mutex { Mutex { sem: Sem((*self.sem).clone()) } }
} }
@ -610,7 +610,7 @@ struct RWlockReleaseRead {
lock: &RWlock, lock: &RWlock,
} }
impl RWlockReleaseRead : Drop { impl Drop for RWlockReleaseRead {
fn finalize(&self) { fn finalize(&self) {
unsafe { unsafe {
do task::unkillable { do task::unkillable {
@ -644,7 +644,7 @@ struct RWlockReleaseDowngrade {
lock: &RWlock, lock: &RWlock,
} }
impl RWlockReleaseDowngrade : Drop { impl Drop for RWlockReleaseDowngrade {
fn finalize(&self) { fn finalize(&self) {
unsafe { unsafe {
do task::unkillable { do task::unkillable {
@ -682,10 +682,10 @@ fn RWlockReleaseDowngrade(lock: &r/RWlock) -> RWlockReleaseDowngrade/&r {
/// The "write permission" token used for rwlock.write_downgrade(). /// The "write permission" token used for rwlock.write_downgrade().
pub struct RWlockWriteMode { priv lock: &RWlock } pub struct RWlockWriteMode { priv lock: &RWlock }
impl RWlockWriteMode : Drop { fn finalize(&self) {} } impl Drop for RWlockWriteMode { fn finalize(&self) {} }
/// The "read permission" token used for rwlock.write_downgrade(). /// The "read permission" token used for rwlock.write_downgrade().
pub struct RWlockReadMode { priv lock: &RWlock } pub struct RWlockReadMode { priv lock: &RWlock }
impl RWlockReadMode : Drop { fn finalize(&self) {} } impl Drop for RWlockReadMode { fn finalize(&self) {} }
impl &RWlockWriteMode { impl &RWlockWriteMode {
/// Access the pre-downgrade rwlock in write mode. /// Access the pre-downgrade rwlock in write mode.
@ -1007,7 +1007,7 @@ mod tests {
c: pipes::Chan<()>, c: pipes::Chan<()>,
} }
impl SendOnFailure : Drop { impl Drop for SendOnFailure {
fn finalize(&self) { fn finalize(&self) {
self.c.send(()); self.c.send(());
} }

View file

@ -54,14 +54,14 @@ impl Timespec {
} }
} }
impl Timespec : Eq { impl Eq for Timespec {
pure fn eq(&self, other: &Timespec) -> bool { pure fn eq(&self, other: &Timespec) -> bool {
self.sec == other.sec && self.nsec == other.nsec self.sec == other.sec && self.nsec == other.nsec
} }
pure fn ne(&self, other: &Timespec) -> bool { !self.eq(other) } pure fn ne(&self, other: &Timespec) -> bool { !self.eq(other) }
} }
impl Timespec : Ord { impl Ord for Timespec {
pure fn lt(&self, other: &Timespec) -> bool { pure fn lt(&self, other: &Timespec) -> bool {
self.sec < other.sec || self.sec < other.sec ||
(self.sec == other.sec && self.nsec < other.nsec) (self.sec == other.sec && self.nsec < other.nsec)
@ -129,7 +129,7 @@ pub struct Tm {
tm_nsec: i32, // nanoseconds tm_nsec: i32, // nanoseconds
} }
impl Tm : Eq { impl Eq for Tm {
pure fn eq(&self, other: &Tm) -> bool { pure fn eq(&self, other: &Tm) -> bool {
self.tm_sec == (*other).tm_sec && self.tm_sec == (*other).tm_sec &&
self.tm_min == (*other).tm_min && self.tm_min == (*other).tm_min &&

View file

@ -39,7 +39,7 @@ pub struct TreeMap<K, V> {
priv length: uint priv length: uint
} }
impl <K: Eq Ord, V: Eq> TreeMap<K, V>: Eq { impl<K: Eq Ord, V: Eq> Eq for TreeMap<K, V> {
pure fn eq(&self, other: &TreeMap<K, V>) -> bool { pure fn eq(&self, other: &TreeMap<K, V>) -> bool {
if self.len() != other.len() { if self.len() != other.len() {
false false
@ -85,7 +85,7 @@ pure fn lt<K: Ord, V>(a: &TreeMap<K, V>, b: &TreeMap<K, V>) -> bool {
return a_len < b_len; return a_len < b_len;
} }
impl <K: Ord, V> TreeMap<K, V>: Ord { impl<K: Ord, V> Ord for TreeMap<K, V> {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &TreeMap<K, V>) -> bool { pure fn lt(&self, other: &TreeMap<K, V>) -> bool {
lt(self, other) lt(self, other)
@ -104,7 +104,7 @@ impl <K: Ord, V> TreeMap<K, V>: Ord {
} }
} }
impl <K: Ord, V> TreeMap<K, V>: BaseIter<(&K, &V)> { impl<K: Ord, V> BaseIter<(&K, &V)> for TreeMap<K, V> {
/// Visit all key-value pairs in order /// Visit all key-value pairs in order
pure fn each(&self, f: fn(&(&self/K, &self/V)) -> bool) { pure fn each(&self, f: fn(&(&self/K, &self/V)) -> bool) {
each(&self.root, f) each(&self.root, f)
@ -112,14 +112,14 @@ impl <K: Ord, V> TreeMap<K, V>: BaseIter<(&K, &V)> {
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
} }
impl <K: Ord, V> TreeMap<K, V>: ReverseIter<(&K, &V)> { impl<K: Ord, V> ReverseIter<(&K, &V)> for TreeMap<K, V> {
/// Visit all key-value pairs in reverse order /// Visit all key-value pairs in reverse order
pure fn each_reverse(&self, f: fn(&(&self/K, &self/V)) -> bool) { pure fn each_reverse(&self, f: fn(&(&self/K, &self/V)) -> bool) {
each_reverse(&self.root, f); each_reverse(&self.root, f);
} }
} }
impl <K: Ord, V> TreeMap<K, V>: Container { impl<K: Ord, V> Container for TreeMap<K, V> {
/// Return the number of elements in the map /// Return the number of elements in the map
pure fn len(&self) -> uint { self.length } pure fn len(&self) -> uint { self.length }
@ -127,7 +127,7 @@ impl <K: Ord, V> TreeMap<K, V>: Container {
pure fn is_empty(&self) -> bool { self.root.is_none() } pure fn is_empty(&self) -> bool { self.root.is_none() }
} }
impl <K: Ord, V> TreeMap<K, V>: Mutable { impl<K: Ord, V> Mutable for TreeMap<K, V> {
/// Clear the map, removing all key-value pairs. /// Clear the map, removing all key-value pairs.
fn clear(&mut self) { fn clear(&mut self) {
self.root = None; self.root = None;
@ -135,7 +135,7 @@ impl <K: Ord, V> TreeMap<K, V>: Mutable {
} }
} }
impl <K: Ord, V> TreeMap<K, V>: Map<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 /// Return true if the map contains a value for the specified key
pure fn contains_key(&self, key: &K) -> bool { pure fn contains_key(&self, key: &K) -> bool {
self.find(key).is_some() self.find(key).is_some()
@ -246,25 +246,25 @@ pub struct TreeSet<T> {
priv map: TreeMap<T, ()> priv map: TreeMap<T, ()>
} }
impl <T: Ord> TreeSet<T>: BaseIter<T> { impl<T: Ord> BaseIter<T> for TreeSet<T> {
/// Visit all values in order /// Visit all values in order
pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) } pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) }
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
} }
impl <T: Ord> TreeSet<T>: ReverseIter<T> { impl<T: Ord> ReverseIter<T> for TreeSet<T> {
/// Visit all values in reverse order /// Visit all values in reverse order
pure fn each_reverse(&self, f: fn(&T) -> bool) { pure fn each_reverse(&self, f: fn(&T) -> bool) {
self.map.each_key_reverse(f) self.map.each_key_reverse(f)
} }
} }
impl <T: Eq Ord> TreeSet<T>: Eq { impl<T: Eq Ord> Eq for TreeSet<T> {
pure fn eq(&self, other: &TreeSet<T>) -> bool { self.map == other.map } pure fn eq(&self, other: &TreeSet<T>) -> bool { self.map == other.map }
pure fn ne(&self, other: &TreeSet<T>) -> bool { self.map != other.map } pure fn ne(&self, other: &TreeSet<T>) -> bool { self.map != other.map }
} }
impl <T: Ord> TreeSet<T>: Ord { impl<T: Ord> Ord for TreeSet<T> {
#[inline(always)] #[inline(always)]
pure fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map } pure fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map }
#[inline(always)] #[inline(always)]
@ -275,7 +275,7 @@ impl <T: Ord> TreeSet<T>: Ord {
pure fn gt(&self, other: &TreeSet<T>) -> bool { self.map > other.map } pure fn gt(&self, other: &TreeSet<T>) -> bool { self.map > other.map }
} }
impl <T: Ord> TreeSet<T>: Container { impl<T: Ord> Container for TreeSet<T> {
/// Return the number of elements in the set /// Return the number of elements in the set
pure fn len(&self) -> uint { self.map.len() } pure fn len(&self) -> uint { self.map.len() }
@ -283,12 +283,12 @@ impl <T: Ord> TreeSet<T>: Container {
pure fn is_empty(&self) -> bool { self.map.is_empty() } pure fn is_empty(&self) -> bool { self.map.is_empty() }
} }
impl <T: Ord> TreeSet<T>: Mutable { impl<T: Ord> Mutable for TreeSet<T> {
/// Clear the set, removing all values. /// Clear the set, removing all values.
fn clear(&mut self) { self.map.clear() } fn clear(&mut self) { self.map.clear() }
} }
impl <T: Ord> TreeSet<T>: Set<T> { impl<T: Ord> Set<T> for TreeSet<T> {
/// Return true if the set contains a value /// Return true if the set contains a value
pure fn contains(&self, value: &T) -> bool { pure fn contains(&self, value: &T) -> bool {
self.map.contains_key(value) self.map.contains_key(value)

View file

@ -51,7 +51,7 @@ fn get_monitor_task_gl() -> IoTask {
struct GlobalIoTask(IoTask); struct GlobalIoTask(IoTask);
impl GlobalIoTask: Clone { impl Clone for GlobalIoTask {
fn clone(&self) -> GlobalIoTask { fn clone(&self) -> GlobalIoTask {
GlobalIoTask((**self).clone()) GlobalIoTask((**self).clone())
} }

View file

@ -31,7 +31,7 @@ pub struct IoTask {
op_chan: SharedChan<IoTaskMsg> op_chan: SharedChan<IoTaskMsg>
} }
impl IoTask: Clone { impl Clone for IoTask {
fn clone(&self) -> IoTask { fn clone(&self) -> IoTask {
IoTask{ IoTask{
async_handle: self.async_handle, async_handle: self.async_handle,

View file

@ -104,7 +104,7 @@ struct WorkKey {
name: ~str name: ~str
} }
impl WorkKey: to_bytes::IterBytes { impl to_bytes::IterBytes for WorkKey {
#[inline(always)] #[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) { pure fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
let mut flag = true; let mut flag = true;
@ -114,7 +114,7 @@ impl WorkKey: to_bytes::IterBytes {
} }
} }
impl WorkKey: cmp::Ord { impl cmp::Ord for WorkKey {
pure fn lt(&self, other: &WorkKey) -> bool { pure fn lt(&self, other: &WorkKey) -> bool {
self.kind < other.kind || self.kind < other.kind ||
(self.kind == other.kind && (self.kind == other.kind &&
@ -285,7 +285,7 @@ trait TPrep {
Decodable<json::Decoder>>(&self, blk: ~fn(&Exec) -> T) -> Work<T>; Decodable<json::Decoder>>(&self, blk: ~fn(&Exec) -> T) -> Work<T>;
} }
impl @Mut<Prep> : TPrep { impl TPrep for @Mut<Prep> {
fn declare_input(&self, kind:&str, name:&str, val:&str) { fn declare_input(&self, kind:&str, name:&str, val:&str) {
do self.borrow_mut |p| { do self.borrow_mut |p| {
p.declared_inputs.insert(WorkKey::new(kind, name), p.declared_inputs.insert(WorkKey::new(kind, name),

View file

@ -326,7 +326,7 @@ pub enum inline_attr {
ia_never, ia_never,
} }
impl inline_attr : cmp::Eq { impl cmp::Eq for inline_attr {
pure fn eq(&self, other: &inline_attr) -> bool { pure fn eq(&self, other: &inline_attr) -> bool {
((*self) as uint) == ((*other) as uint) ((*self) as uint) == ((*other) as uint)
} }

View file

@ -63,7 +63,7 @@ struct CodemapT {
cm: @codemap::CodeMap, cm: @codemap::CodeMap,
} }
impl CodemapT: span_handler { impl span_handler for CodemapT {
fn span_fatal(@mut self, sp: span, msg: &str) -> ! { fn span_fatal(@mut self, sp: span, msg: &str) -> ! {
self.handler.emit(Some((self.cm, sp)), msg, fatal); self.handler.emit(Some((self.cm, sp)), msg, fatal);
fail!(); fail!();
@ -89,7 +89,7 @@ impl CodemapT: span_handler {
} }
} }
impl HandlerT: handler { impl handler for HandlerT {
fn fatal(@mut self, msg: &str) -> ! { fn fatal(@mut self, msg: &str) -> ! {
(self.emit)(None, msg, fatal); (self.emit)(None, msg, fatal);
fail!(); fail!();

View file

@ -23,7 +23,7 @@ For example, a type like:
would generate two implementations like: would generate two implementations like:
impl<S: std::serialize::Encoder> Node: Encodable<S> { impl<S: std::serialize::Encoder> Encodable<S> for Node {
fn encode(&self, s: &S) { fn encode(&self, s: &S) {
do s.emit_struct("Node", 1) { do s.emit_struct("Node", 1) {
s.emit_field("id", 0, || s.emit_uint(self.id)) s.emit_field("id", 0, || s.emit_uint(self.id))
@ -31,7 +31,7 @@ impl<S: std::serialize::Encoder> Node: Encodable<S> {
} }
} }
impl<D: Decoder> node_id: Decodable { impl<D: Decoder> Decodable for node_id {
static fn decode(d: &D) -> Node { static fn decode(d: &D) -> Node {
do d.read_struct("Node", 1) { do d.read_struct("Node", 1) {
Node { Node {

View file

@ -197,7 +197,7 @@ pub fn mk_ctxt(parse_sess: parse::parse_sess,
mod_path: ~[ast::ident], mod_path: ~[ast::ident],
trace_mac: bool trace_mac: bool
} }
impl CtxtRepr: ext_ctxt { impl ext_ctxt for CtxtRepr {
fn codemap(@mut self) -> @CodeMap { self.parse_sess.cm } fn codemap(@mut self) -> @CodeMap { self.parse_sess.cm }
fn parse_sess(@mut self) -> parse::parse_sess { self.parse_sess } fn parse_sess(@mut self) -> parse::parse_sess { self.parse_sess }
fn cfg(@mut self) -> ast::crate_cfg { self.cfg } fn cfg(@mut self) -> ast::crate_cfg { self.cfg }

View file

@ -53,7 +53,7 @@ pub mod rt {
pub fn to_tokens(_cx: ext_ctxt) -> ~[token_tree]; pub fn to_tokens(_cx: ext_ctxt) -> ~[token_tree];
} }
impl ~[token_tree]: ToTokens { impl ToTokens for ~[token_tree] {
pub fn to_tokens(_cx: ext_ctxt) -> ~[token_tree] { pub fn to_tokens(_cx: ext_ctxt) -> ~[token_tree] {
copy self copy self
} }
@ -78,43 +78,43 @@ pub mod rt {
pub fn to_source(cx: ext_ctxt) -> ~str; pub fn to_source(cx: ext_ctxt) -> ~str;
} }
impl ast::ident: ToSource { impl ToSource for ast::ident {
fn to_source(cx: ext_ctxt) -> ~str { fn to_source(cx: ext_ctxt) -> ~str {
copy *cx.parse_sess().interner.get(self) copy *cx.parse_sess().interner.get(self)
} }
} }
impl @ast::item: ToSource { impl ToSource for @ast::item {
fn to_source(cx: ext_ctxt) -> ~str { fn to_source(cx: ext_ctxt) -> ~str {
item_to_str(self, cx.parse_sess().interner) item_to_str(self, cx.parse_sess().interner)
} }
} }
impl ~[@ast::item]: ToSource { impl ToSource for ~[@ast::item] {
fn to_source(cx: ext_ctxt) -> ~str { fn to_source(cx: ext_ctxt) -> ~str {
str::connect(self.map(|i| i.to_source(cx)), ~"\n\n") str::connect(self.map(|i| i.to_source(cx)), ~"\n\n")
} }
} }
impl @ast::Ty: ToSource { impl ToSource for @ast::Ty {
fn to_source(cx: ext_ctxt) -> ~str { fn to_source(cx: ext_ctxt) -> ~str {
ty_to_str(self, cx.parse_sess().interner) ty_to_str(self, cx.parse_sess().interner)
} }
} }
impl ~[@ast::Ty]: ToSource { impl ToSource for ~[@ast::Ty] {
fn to_source(cx: ext_ctxt) -> ~str { fn to_source(cx: ext_ctxt) -> ~str {
str::connect(self.map(|i| i.to_source(cx)), ~", ") str::connect(self.map(|i| i.to_source(cx)), ~", ")
} }
} }
impl ~[ast::ty_param]: ToSource { impl ToSource for ~[ast::ty_param] {
fn to_source(cx: ext_ctxt) -> ~str { fn to_source(cx: ext_ctxt) -> ~str {
pprust::typarams_to_str(self, cx.parse_sess().interner) pprust::typarams_to_str(self, cx.parse_sess().interner)
} }
} }
impl @ast::expr: ToSource { impl ToSource for @ast::expr {
fn to_source(cx: ext_ctxt) -> ~str { fn to_source(cx: ext_ctxt) -> ~str {
pprust::expr_to_str(self, cx.parse_sess().interner) pprust::expr_to_str(self, cx.parse_sess().interner)
} }
@ -122,43 +122,43 @@ pub mod rt {
// Alas ... we write these out instead. All redundant. // Alas ... we write these out instead. All redundant.
impl ast::ident: ToTokens { impl ToTokens for ast::ident {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] { fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl @ast::item: ToTokens { impl ToTokens for @ast::item {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] { fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ~[@ast::item]: ToTokens { impl ToTokens for ~[@ast::item] {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] { fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl @ast::Ty: ToTokens { impl ToTokens for @ast::Ty {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] { fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ~[@ast::Ty]: ToTokens { impl ToTokens for ~[@ast::Ty] {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] { fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl ~[ast::ty_param]: ToTokens { impl ToTokens for ~[ast::ty_param] {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] { fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
} }
impl @ast::expr: ToTokens { impl ToTokens for @ast::expr {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] { fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
@ -171,7 +171,7 @@ pub mod rt {
fn parse_tts(s: ~str) -> ~[ast::token_tree]; fn parse_tts(s: ~str) -> ~[ast::token_tree];
} }
impl ext_ctxt: ExtParseUtils { impl ExtParseUtils for ext_ctxt {
fn parse_item(s: ~str) -> @ast::item { fn parse_item(s: ~str) -> @ast::item {
let res = parse::parse_item_from_source_str( let res = parse::parse_item_from_source_str(

View file

@ -30,7 +30,7 @@ pub trait parser_attr {
fn parse_optional_meta() -> ~[@ast::meta_item]; fn parse_optional_meta() -> ~[@ast::meta_item];
} }
impl Parser: parser_attr { impl parser_attr for Parser {
// Parse attributes that appear before an item // Parse attributes that appear before an item
fn parse_outer_attributes() -> ~[ast::attribute] { fn parse_outer_attributes() -> ~[ast::attribute] {

View file

@ -34,7 +34,7 @@ pub enum cmnt_style {
blank_line, // Just a manual blank line "\n\n", for layout blank_line, // Just a manual blank line "\n\n", for layout
} }
impl cmnt_style : cmp::Eq { impl cmp::Eq for cmnt_style {
pure fn eq(&self, other: &cmnt_style) -> bool { pure fn eq(&self, other: &cmnt_style) -> bool {
((*self) as uint) == ((*other) as uint) ((*self) as uint) == ((*other) as uint)
} }

View file

@ -108,7 +108,7 @@ fn dup_string_reader(r: @mut StringReader) -> @mut StringReader {
} }
} }
impl StringReader: reader { impl reader for StringReader {
fn is_eof(@mut self) -> bool { is_eof(self) } fn is_eof(@mut self) -> bool { is_eof(self) }
// return the next token. EFFECT: advances the string_reader. // return the next token. EFFECT: advances the string_reader.
fn next_token(@mut self) -> TokenAndSpan { fn next_token(@mut self) -> TokenAndSpan {

View file

@ -520,7 +520,7 @@ pub fn reserved_keyword_table() -> HashMap<~str, ()> {
} }
impl Token : cmp::Eq { impl cmp::Eq for Token {
pure fn eq(&self, other: &Token) -> bool { pure fn eq(&self, other: &Token) -> bool {
match (*self) { match (*self) {
EQ => { EQ => {

View file

@ -11,4 +11,4 @@
trait me { trait me {
fn me() -> uint; fn me() -> uint;
} }
impl uint: me { fn me() -> uint { self } } impl me for uint { fn me() -> uint { self } }

View file

@ -14,7 +14,7 @@ trait uint_helpers {
fn to(v: uint, f: fn(uint)); fn to(v: uint, f: fn(uint));
} }
impl uint: uint_helpers { impl uint_helpers for uint {
#[inline] #[inline]
fn to(v: uint, f: fn(uint)) { fn to(v: uint, f: fn(uint)) {
let mut i = self; let mut i = self;

View file

@ -17,7 +17,7 @@ pub struct Bar {
x: ~str x: ~str
} }
impl Bar : Foo { impl Foo for Bar {
#[inline(always)] #[inline(always)]
fn f(&self) { fn f(&self) {
io::println((*self).x); io::println((*self).x);

View file

@ -6,7 +6,7 @@ pub struct Fish {
mod unexported { mod unexported {
use super::Fish; use super::Fish;
impl Fish : Eq { impl Eq for Fish {
pure fn eq(&self, _: &Fish) -> bool { true } pure fn eq(&self, _: &Fish) -> bool { true }
pure fn ne(&self, _: &Fish) -> bool { false } pure fn ne(&self, _: &Fish) -> bool { false }
} }

View file

@ -14,7 +14,7 @@
pub trait i<T> { } pub trait i<T> { }
pub fn f<T>() -> i<T> { pub fn f<T>() -> i<T> {
impl<T> (): i<T> { } impl<T> i<T> for () { }
() as i::<T> () as i::<T>
} }

View file

@ -17,7 +17,7 @@ trait foo {
fn foo(); fn foo();
} }
impl ~str: foo { impl foo for ~str {
fn foo() {} fn foo() {}
} }

View file

@ -19,7 +19,7 @@ struct arc_destruct<T> {
_data: int, _data: int,
} }
impl<T:Const> arc_destruct<T> : Drop { impl<T:Const> Drop for arc_destruct<T> {
fn finalize(&self) {} fn finalize(&self) {}
} }
@ -43,7 +43,7 @@ struct context_res {
ctx : int, ctx : int,
} }
impl context_res : Drop { impl Drop for context_res {
fn finalize(&self) {} fn finalize(&self) {}
} }

Some files were not shown because too many files have changed in this diff Show more