pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
#[cfg(notest)]
-impl bool : cmp::Eq {
+impl cmp::Eq for bool {
pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
}
}
#[cfg(notest)]
-impl char : Eq {
+impl Eq for char {
pure fn eq(&self, other: &char) -> bool { (*self) == (*other) }
pure fn ne(&self, other: &char) -> bool { (*self) != (*other) }
}
fn clone(&self) -> Self;
}
-impl (): Clone {
+impl Clone for () {
#[inline(always)]
fn clone(&self) -> () { () }
}
cond: &Condition<T, U>
}
-impl<T, U> Guard<T, U> : Drop {
+impl<T, U> Drop for Guard<T, U> {
fn finalize(&self) {
unsafe {
debug!("Guard: popping handler from TLS");
}
}
-impl<A:Copy> DVec<A>: Index<uint,A> {
+impl<A:Copy> Index<uint,A> for DVec<A> {
#[inline(always)]
pure fn index(&self, idx: uint) -> A {
self.get_elt(idx)
pure fn hash() -> u64;
}
-impl <A: Hash> A: HashUtil {
+impl<A: Hash> HashUtil for A {
#[inline(always)]
pure fn hash() -> u64 { self.hash_keyed(0,0) }
}
fn reset();
}
-impl <A: IterBytes> A: Hash {
+impl<A: IterBytes> Hash for A {
#[inline(always)]
pure fn hash_keyed(k0: u64, k1: u64) -> u64 {
unsafe {
}
-impl SipState : io::Writer {
+impl io::Writer for SipState {
// Methods for io::writer
#[inline(always)]
}
}
-impl &SipState : Streaming {
+impl Streaming for &SipState {
#[inline(always)]
fn input(buf: &[const u8]) {
}
}
- impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: BaseIter<(&K, &V)> {
+ impl<K: Hash IterBytes Eq, V> BaseIter<(&K, &V)> for LinearMap<K, V> {
/// Visit all key-value pairs
pure fn each(&self, blk: fn(&(&self/K, &self/V)) -> bool) {
for uint::range(0, self.buckets.len()) |i| {
}
- impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: Container {
+ impl<K: Hash IterBytes Eq, V> Container for LinearMap<K, V> {
/// Return the number of elements in the map
pure fn len(&self) -> uint { self.size }
pure fn is_empty(&self) -> bool { self.len() == 0 }
}
- impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: Mutable {
+ impl<K: Hash IterBytes Eq, V> Mutable for LinearMap<K, V> {
/// Clear the map, removing all key-value pairs.
fn clear(&mut self) {
for uint::range(0, self.buckets.len()) |idx| {
}
}
- impl <K: Hash IterBytes Eq, V> LinearMap<K, V>: Map<K, V> {
+ impl<K: Hash IterBytes Eq, V> Map<K, V> for LinearMap<K, V> {
/// Return true if the map contains a value for the specified key
pure fn contains_key(&self, k: &K) -> bool {
match self.bucket_for_key(k) {
}
}
- impl<K: Hash IterBytes Eq, V: Eq> LinearMap<K, V>: Eq {
+ impl<K: Hash IterBytes Eq, V: Eq> Eq for LinearMap<K, V> {
pure fn eq(&self, other: &LinearMap<K, V>) -> bool {
if self.len() != other.len() { return false; }
priv map: LinearMap<T, ()>
}
- impl <T: Hash IterBytes Eq> LinearSet<T>: BaseIter<T> {
+ impl<T: Hash IterBytes Eq> BaseIter<T> for LinearSet<T> {
/// Visit all values in order
pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) }
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
- impl <T: Hash IterBytes Eq> LinearSet<T>: Eq {
+ impl<T: Hash IterBytes Eq> Eq for LinearSet<T> {
pure fn eq(&self, other: &LinearSet<T>) -> bool {
self.map == other.map
}
}
}
- impl <T: Hash IterBytes Eq> LinearSet<T>: Container {
+ impl<T: Hash IterBytes Eq> Container for LinearSet<T> {
/// Return the number of elements in the set
pure fn len(&self) -> uint { self.map.len() }
pure fn is_empty(&self) -> bool { self.map.is_empty() }
}
- impl <T: Hash IterBytes Eq> LinearSet<T>: Mutable {
+ impl<T: Hash IterBytes Eq> Mutable for LinearSet<T> {
/// Clear the set, removing all values.
fn clear(&mut self) { self.map.clear() }
}
- impl <T: Hash IterBytes Eq> LinearSet<T>: Set<T> {
+ impl<T: Hash IterBytes Eq> Set<T> for LinearSet<T> {
/// Return true if the set contains a value
pure fn contains(&self, value: &T) -> bool {
self.map.contains_key(value)
fn read_i8(&self) -> i8;
}
-impl<T: Reader> T : ReaderUtil {
+impl<T: Reader> ReaderUtil for T {
fn read_bytes(&self,len: uint) -> ~[u8] {
let mut bytes = vec::with_capacity(len);
};
}
-impl *libc::FILE: Reader {
+impl Reader for *libc::FILE {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
unsafe {
do vec::as_mut_buf(bytes) |buf_p, buf_len| {
// A forwarding impl of reader that also holds on to a resource for the
// duration of its lifetime.
// FIXME there really should be a better way to do this // #2004
-impl<R: Reader, C> Wrapper<R, C>: Reader {
+impl<R: Reader, C> Reader for Wrapper<R, C> {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
self.base.read(bytes, len)
}
mut pos: uint
}
-impl BytesReader: Reader {
+impl Reader for BytesReader {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
let count = uint::min(len, self.bytes.len() - self.pos);
fn get_type(&self) -> WriterType;
}
-impl<W: Writer, C> Wrapper<W, C>: Writer {
+impl<W: Writer, C> Writer for Wrapper<W, C> {
fn write(&self, bs: &[const u8]) { self.base.write(bs); }
fn seek(&self, off: int, style: SeekStyle) { self.base.seek(off, style); }
fn tell(&self) -> uint { self.base.tell() }
fn get_type(&self) -> WriterType { File }
}
-impl *libc::FILE: Writer {
+impl Writer for *libc::FILE {
fn write(&self, v: &[const u8]) {
unsafe {
do vec::as_const_buf(v) |vbuf, len| {
}
}
-impl fd_t: Writer {
+impl Writer for fd_t {
fn write(&self, v: &[const u8]) {
unsafe {
let mut count = 0u;
fn write_i8(&self, n: i8);
}
-impl<T: Writer> T : WriterUtil {
+impl<T: Writer> WriterUtil for T {
fn write_char(&self, ch: char) {
if ch as uint < 128u {
self.write(&[ch as u8]);
mut pos: uint,
}
-impl BytesWriter: Writer {
+impl Writer for BytesWriter {
fn write(&self, v: &[const u8]) {
do self.bytes.swap |bytes| {
let mut bytes = move bytes;
arg: Arg<t>,
}
- impl<T: Copy> Res<T>: Drop {
+ impl<T: Copy> Drop for Res<T> {
fn finalize(&self) {
match self.arg.opt_level {
None => (),
use self::inst::{IMPL_T, EACH, SIZE_HINT};
-impl<A> IMPL_T<A>: iter::BaseIter<A> {
+impl<A> iter::BaseIter<A> for IMPL_T<A> {
#[inline(always)]
pure fn each(&self, blk: fn(v: &A) -> bool) { EACH(self, blk) }
#[inline(always)]
pure fn size_hint(&self) -> Option<uint> { SIZE_HINT(self) }
}
-impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
+impl<A> iter::ExtendedIter<A> for IMPL_T<A> {
#[inline(always)]
pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
iter::eachi(self, blk)
}
-impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
+impl<A: Eq> iter::EqIter<A> for IMPL_T<A> {
#[inline(always)]
pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
#[inline(always)]
pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
}
-impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
+impl<A: Copy> iter::CopyableIter<A> for IMPL_T<A> {
#[inline(always)]
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
iter::filter_to_vec(self, pred)
}
}
-impl<A: Copy Ord> IMPL_T<A>: iter::CopyableOrderedIter<A> {
+impl<A: Copy Ord> iter::CopyableOrderedIter<A> for IMPL_T<A> {
#[inline(always)]
pure fn min(&self) -> A { iter::min(self) }
#[inline(always)]
}
#[cfg(notest)]
-impl<T:Eq> @const T : Eq {
+impl<T:Eq> Eq for @const T {
#[inline(always)]
pure fn eq(&self, other: &@const T) -> bool { *(*self) == *(*other) }
#[inline(always)]
}
#[cfg(notest)]
-impl<T:Ord> @const T : Ord {
+impl<T:Ord> Ord for @const T {
#[inline(always)]
pure fn lt(&self, other: &@const T) -> bool { *(*self) < *(*other) }
#[inline(always)]
use cmp::{Eq, Ord};
#[cfg(notest)]
-impl () : Eq {
+impl Eq for () {
#[inline(always)]
pure fn eq(&self, _other: &()) -> bool { true }
#[inline(always)]
}
#[cfg(notest)]
-impl () : Ord {
+impl Ord for () {
#[inline(always)]
pure fn lt(&self, _other: &()) -> bool { false }
#[inline(always)]
}
#[cfg(notest)]
-impl f32 : cmp::Eq {
+impl cmp::Eq for f32 {
#[inline(always)]
pure fn eq(&self, other: &f32) -> bool { (*self) == (*other) }
#[inline(always)]
}
#[cfg(notest)]
-impl f32 : cmp::Ord {
+impl cmp::Ord for f32 {
#[inline(always)]
pure fn lt(&self, other: &f32) -> bool { (*self) < (*other) }
#[inline(always)]
pure fn gt(&self, other: &f32) -> bool { (*self) > (*other) }
}
-impl f32: num::Zero {
+impl num::Zero for f32 {
#[inline(always)]
static pure fn zero() -> f32 { 0.0 }
}
-impl f32: num::One {
+impl num::One for f32 {
#[inline(always)]
static pure fn one() -> f32 { 1.0 }
}
fn floorf32(val: f32) -> f32;
}
-impl f32: num::Round {
+impl num::Round for f32 {
#[inline(always)]
pure fn round(&self, mode: num::RoundMode) -> f32 {
match mode {
r
}
-impl f32: to_str::ToStr {
+impl to_str::ToStr for f32 {
#[inline(always)]
pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
}
-impl f32: num::ToStrRadix {
+impl num::ToStrRadix for f32 {
#[inline(always)]
pure fn to_str_radix(&self, rdx: uint) -> ~str {
to_str_radix(*self, rdx)
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)]
static pure fn from_str(val: &str) -> Option<f32> { from_str(val) }
}
-impl f32: num::FromStrRadix {
+impl num::FromStrRadix for f32 {
#[inline(always)]
static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f32> {
from_str_radix(val, rdx)
}
#[cfg(notest)]
-impl f64 : cmp::Eq {
+impl cmp::Eq for f64 {
#[inline(always)]
pure fn eq(&self, other: &f64) -> bool { (*self) == (*other) }
#[inline(always)]
}
#[cfg(notest)]
-impl f64 : cmp::Ord {
+impl cmp::Ord for f64 {
#[inline(always)]
pure fn lt(&self, other: &f64) -> bool { (*self) < (*other) }
#[inline(always)]
#[inline(always)] pure fn to_float(&self) -> float { *self as float }
}
-impl f64: num::Zero {
+impl num::Zero for f64 {
#[inline(always)]
static pure fn zero() -> f64 { 0.0 }
}
-impl f64: num::One {
+impl num::One for f64 {
#[inline(always)]
static pure fn one() -> f64 { 1.0 }
}
fn floorf64(val: f64) -> f64;
}
-impl f64: num::Round {
+impl num::Round for f64 {
#[inline(always)]
pure fn round(&self, mode: num::RoundMode) -> f64 {
match mode {
r
}
-impl f64: to_str::ToStr {
+impl to_str::ToStr for f64 {
#[inline(always)]
pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
}
-impl f64: num::ToStrRadix {
+impl num::ToStrRadix for f64 {
#[inline(always)]
pure fn to_str_radix(&self, rdx: uint) -> ~str {
to_str_radix(*self, rdx)
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)]
static pure fn from_str(val: &str) -> Option<f64> { from_str(val) }
}
-impl f64: num::FromStrRadix {
+impl num::FromStrRadix for f64 {
#[inline(always)]
static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f64> {
from_str_radix(val, rdx)
r
}
-impl float: to_str::ToStr {
+impl to_str::ToStr for float {
#[inline(always)]
pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
}
-impl float: num::ToStrRadix {
+impl num::ToStrRadix for float {
#[inline(always)]
pure fn to_str_radix(&self, radix: uint) -> ~str {
to_str_radix(*self, radix)
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)]
static pure fn from_str(val: &str) -> Option<float> { from_str(val) }
}
-impl float: num::FromStrRadix {
+impl num::FromStrRadix for float {
#[inline(always)]
static pure fn from_str_radix(val: &str, radix: uint) -> Option<float> {
from_str_radix(val, radix)
}
#[cfg(notest)]
-impl float : Eq {
+impl Eq for float {
pure fn eq(&self, other: &float) -> bool { (*self) == (*other) }
pure fn ne(&self, other: &float) -> bool { (*self) != (*other) }
}
#[cfg(notest)]
-impl float : Ord {
+impl Ord for float {
pure fn lt(&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 gt(&self, other: &float) -> bool { (*self) > (*other) }
}
-impl float: num::Zero {
+impl num::Zero for float {
#[inline(always)]
static pure fn zero() -> float { 0.0 }
}
-impl float: num::One {
+impl num::One for float {
#[inline(always)]
static pure fn one() -> float { 1.0 }
}
#[inline(always)] pure fn to_float(&self) -> float { *self }
}
-impl float: num::Round {
+impl num::Round for float {
#[inline(always)]
pure fn round(&self, mode: num::RoundMode) -> float {
match mode {
}
#[cfg(notest)]
-impl T : Ord {
+impl Ord for T {
#[inline(always)]
pure fn lt(&self, other: &T) -> bool { return (*self) < (*other); }
#[inline(always)]
}
#[cfg(notest)]
-impl T : Eq {
+impl Eq for T {
#[inline(always)]
pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); }
#[inline(always)]
pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); }
}
-impl T: num::Zero {
+impl num::Zero for T {
#[inline(always)]
static pure fn zero() -> T { 0 }
}
-impl T: num::One {
+impl num::One for T {
#[inline(always)]
static pure fn one() -> T { 1 }
}
-impl T: num::Round {
+impl num::Round for T {
#[inline(always)]
pure fn round(&self, _: num::RoundMode) -> T { *self }
num::ExpNone, false)
}
-impl T : FromStr {
+impl FromStr for T {
#[inline(always)]
static pure fn from_str(s: &str) -> Option<T> {
from_str(s)
}
}
-impl T : FromStrRadix {
+impl FromStrRadix for T {
#[inline(always)]
static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> {
from_str_radix(s, radix)
#[inline(always)]
pub pure fn str(i: T) -> ~str { to_str(i) }
-impl T : ToStr {
+impl ToStr for T {
#[inline(always)]
pure fn to_str(&self) -> ~str {
to_str(*self)
}
}
-impl T : ToStrRadix {
+impl ToStrRadix for T {
#[inline(always)]
pure fn to_str_radix(&self, radix: uint) -> ~str {
to_str_radix(*self, radix)
assert (20i16 == num::cast(20f));
assert (20i16 == num::cast(20f32));
assert (20i16 == num::cast(20f64));
-}
\ No newline at end of file
+}
assert (20i32 == num::cast(20f));
assert (20i32 == num::cast(20f32));
assert (20i32 == num::cast(20f64));
-}
\ No newline at end of file
+}
}
#[cfg(notest)]
-impl T : Ord {
+impl Ord for T {
#[inline(always)]
pure fn lt(&self, other: &T) -> bool { (*self) < (*other) }
#[inline(always)]
}
#[cfg(notest)]
-impl T : Eq {
+impl Eq for T {
#[inline(always)]
pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); }
#[inline(always)]
pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); }
}
-impl T: num::Zero {
+impl num::Zero for T {
#[inline(always)]
static pure fn zero() -> T { 0 }
}
-impl T: num::One {
+impl num::One for T {
#[inline(always)]
static pure fn one() -> T { 1 }
}
-impl T: num::Round {
+impl num::Round for T {
#[inline(always)]
pure fn round(&self, _: num::RoundMode) -> T { *self }
num::ExpNone, false)
}
-impl T : FromStr {
+impl FromStr for T {
#[inline(always)]
static pure fn from_str(s: &str) -> Option<T> {
from_str(s)
}
}
-impl T : FromStrRadix {
+impl FromStrRadix for T {
#[inline(always)]
static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> {
from_str_radix(s, radix)
#[inline(always)]
pub pure fn str(i: T) -> ~str { to_str(i) }
-impl T : ToStr {
+impl ToStr for T {
#[inline(always)]
pure fn to_str(&self) -> ~str {
to_str(*self)
}
}
-impl T : ToStrRadix {
+impl ToStrRadix for T {
#[inline(always)]
pure fn to_str_radix(&self, radix: uint) -> ~str {
to_str_radix(*self, radix)
assert (20u16 == num::cast(20f));
assert (20u16 == num::cast(20f32));
assert (20u16 == num::cast(20f64));
-}
\ No newline at end of file
+}
assert (20u64 == num::cast(20f));
assert (20u64 == num::cast(20f32));
assert (20u64 == num::cast(20f64));
-}
\ No newline at end of file
+}
assert (20u64 == num::cast(20f));
assert (20u64 == num::cast(20f32));
assert (20u64 == num::cast(20f64));
-}
\ No newline at end of file
+}
assert (20u8 == num::cast(20f));
assert (20u8 == num::cast(20f32));
assert (20u8 == num::cast(20f64));
-}
\ No newline at end of file
+}
assert (20u == num::cast(20f));
assert (20u == num::cast(20f32));
assert (20u == num::cast(20f64));
-}
\ No newline at end of file
+}
use cmp::{Eq, Ord};
#[cfg(notest)]
-impl<T:Eq> ~const T : Eq {
+impl<T:Eq> Eq for ~const T {
#[inline(always)]
pure fn eq(&self, other: &~const T) -> bool { *(*self) == *(*other) }
#[inline(always)]
}
#[cfg(notest)]
-impl<T:Ord> ~const T : Ord {
+impl<T:Ord> Ord for ~const T {
#[inline(always)]
pure fn lt(&self, other: &~const T) -> bool { *(*self) < *(*other) }
#[inline(always)]
}
}
-impl PosixPath : ToStr {
+impl ToStr for PosixPath {
pure fn to_str(&self) -> ~str {
let mut s = ~"";
if self.is_absolute {
// FIXME (#3227): when default methods in traits are working, de-duplicate
// PosixPath and WindowsPath, most of their methods are common.
-impl PosixPath : GenericPath {
+impl GenericPath for PosixPath {
static pure fn from_str(s: &str) -> PosixPath {
let mut components = str::split_nonempty(s, |c| c == '/');
}
-impl WindowsPath : ToStr {
+impl ToStr for WindowsPath {
pure fn to_str(&self) -> ~str {
let mut s = ~"";
match self.host {
}
-impl WindowsPath : GenericPath {
+impl GenericPath for WindowsPath {
static pure fn from_str(s: &str) -> WindowsPath {
let host;
Terminated
}
-impl State : Eq {
+impl Eq for State {
pure fn eq(&self, other: &State) -> bool {
((*self) as uint) == ((*other) as uint)
}
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) {
self.header.buffer = b;
}
}
}
-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 {
peek(&self)
}
pure fn header() -> *PacketHeader;
}
-impl *PacketHeader: Selectable {
+impl Selectable for *PacketHeader {
pure fn header() -> *PacketHeader { self }
}
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) {
//if self.p != none {
// debug!("drop send %?", option::get(self.p));
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) {
//if self.p != none {
// debug!("drop recv %?", option::get(self.p));
}
}
-impl<T: Owned, Tbuffer: Owned> RecvPacketBuffered<T, Tbuffer> : Selectable {
+impl<T: Owned, Tbuffer: Owned> Selectable for RecvPacketBuffered<T, Tbuffer> {
pure fn header() -> *PacketHeader {
match self.p {
Some(packet) => unsafe {
(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) {
let mut endp = None;
endp <-> self.endp;
}
}
-impl<T: Owned> Chan<T>: GenericSmartChan<T> {
+impl<T: Owned> GenericSmartChan<T> for Chan<T> {
fn try_send(x: T) -> bool {
let mut endp = None;
}
}
-impl<T: Owned> Port<T>: GenericPort<T> {
+impl<T: Owned> GenericPort<T> for Port<T> {
fn recv() -> T {
let mut endp = None;
endp <-> self.endp;
}
}
-impl<T: Owned> Port<T>: Peekable<T> {
+impl<T: Owned> Peekable<T> for Port<T> {
pure fn peek() -> bool {
unsafe {
let mut endp = None;
}
}
-impl<T: Owned> Port<T>: Selectable {
+impl<T: Owned> Selectable for Port<T> {
pure fn header() -> *PacketHeader {
unsafe {
match self.endp {
}
}
-impl<T: Owned> PortSet<T> : GenericPort<T> {
+impl<T: Owned> GenericPort<T> for PortSet<T> {
fn try_recv() -> Option<T> {
let mut result = None;
}
-impl<T: Owned> PortSet<T> : Peekable<T> {
+impl<T: Owned> Peekable<T> for PortSet<T> {
pure fn peek() -> bool {
// It'd be nice to use self.port.each, but that version isn't
// pure.
/// A channel that can be shared between many senders.
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) {
let mut xx = Some(move x);
do self.with_imm |chan| {
}
}
-impl<T: Owned> SharedChan<T>: GenericSmartChan<T> {
+impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
fn try_send(x: T) -> bool {
let mut xx = Some(move x);
do self.with_imm |chan| {
ArcDestruct((*rc).data)
}
-impl<T: Owned> SharedMutableState<T>: Clone {
+impl<T: Owned> Clone for SharedMutableState<T> {
fn clone(&self) -> SharedMutableState<T> {
unsafe {
clone_shared_mutable_state(self)
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.
fn clone(&self) -> Exclusive<T> {
Exclusive { x: unsafe { clone_shared_mutable_state(&self.x) } }
assert j > i;
}
}
-}
\ No newline at end of file
+}
}
#[cfg(stage0)]
-impl<T> &fn() -> T: Finally<T> {
+impl<T> Finally<T> for &fn() -> T {
// FIXME #4518: Should not require a mode here
fn finally(&self, +dtor: &fn()) -> T {
let _d = Finallyalizer {
#[cfg(stage1)]
#[cfg(stage2)]
#[cfg(stage3)]
-impl<T> &fn() -> T: Finally<T> {
+impl<T> Finally<T> for &fn() -> T {
fn finally(&self, dtor: &fn()) -> T {
let _d = Finallyalizer {
dtor: dtor
dtor: &fn()
}
-impl Finallyalizer: Drop {
+impl Drop for Finallyalizer {
fn finalize(&self) {
(self.dtor)();
}
map: LinearMap<uint, (*c_void, ~fn())>
}
-impl GlobalState: Drop {
+impl Drop for GlobalState {
fn finalize(&self) {
for self.map.each_value |v| {
match v {
}
/// 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.
#[inline(always)]
pure fn is_null() -> bool { is_null(self) }
}
/// 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.
#[inline(always)]
pure fn is_null() -> bool { is_null(self) }
// Equality for pointers
#[cfg(notest)]
-impl<T> *const T : Eq {
+impl<T> Eq for *const T {
#[inline(always)]
pure fn eq(&self, other: &*const T) -> bool {
unsafe {
// Comparison for pointers
#[cfg(notest)]
-impl<T> *const T : Ord {
+impl<T> Ord for *const T {
#[inline(always)]
pure fn lt(&self, other: &*const T) -> bool {
unsafe {
// Equality for region pointers
#[cfg(notest)]
-impl<T:Eq> &const T : Eq {
+impl<T:Eq> Eq for &const T {
#[inline(always)]
pure fn eq(&self, other: & &self/const T) -> bool {
return *(*self) == *(*other);
// Comparison for region pointers
#[cfg(notest)]
-impl<T:Ord> &const T : Ord {
+impl<T:Ord> Ord for &const T {
#[inline(always)]
pure fn lt(&self, other: & &self/const T) -> bool {
*(*self) < *(*other)
static fn rand(rng: rand::Rng) -> Self;
}
-impl int: Rand {
+impl Rand for int {
static fn rand(rng: rand::Rng) -> int {
rng.gen_int()
}
}
-impl i8: Rand {
+impl Rand for i8 {
static fn rand(rng: rand::Rng) -> i8 {
rng.gen_i8()
}
}
-impl i16: Rand {
+impl Rand for i16 {
static fn rand(rng: rand::Rng) -> i16 {
rng.gen_i16()
}
}
-impl i32: Rand {
+impl Rand for i32 {
static fn rand(rng: rand::Rng) -> i32 {
rng.gen_i32()
}
}
-impl i64: Rand {
+impl Rand for i64 {
static fn rand(rng: rand::Rng) -> i64 {
rng.gen_i64()
}
}
-impl u8: Rand {
+impl Rand for u8 {
static fn rand(rng: rand::Rng) -> u8 {
rng.gen_u8()
}
}
-impl u16: Rand {
+impl Rand for u16 {
static fn rand(rng: rand::Rng) -> u16 {
rng.gen_u16()
}
}
-impl u32: Rand {
+impl Rand for u32 {
static fn rand(rng: rand::Rng) -> u32 {
rng.gen_u32()
}
}
-impl u64: Rand {
+impl Rand for u64 {
static fn rand(rng: rand::Rng) -> u64 {
rng.gen_u64()
}
}
-impl float: Rand {
+impl Rand for float {
static fn rand(rng: rand::Rng) -> float {
rng.gen_float()
}
}
-impl f32: Rand {
+impl Rand for f32 {
static fn rand(rng: rand::Rng) -> f32 {
rng.gen_f32()
}
}
-impl f64: Rand {
+impl Rand for f64 {
static fn rand(rng: rand::Rng) -> f64 {
rng.gen_f64()
}
}
-impl char: Rand {
+impl Rand for char {
static fn rand(rng: rand::Rng) -> char {
rng.gen_char()
}
}
-impl bool: Rand {
+impl Rand for bool {
static fn rand(rng: rand::Rng) -> 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> {
if rng.gen_bool() { Some(Rand::rand(rng)) }
else { None }
}
}
-impl @RandRes: Rng {
+impl Rng for @RandRes {
fn next() -> u32 {
unsafe {
return rustrt::rand_next((*self).c);
mut w: u32,
}
-impl XorShiftState: Rng {
+impl Rng for XorShiftState {
fn next() -> u32 {
let x = self.x;
let mut t = x ^ (x << 11);
}
/// 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 {
self.align_to::<()>();
if ! self.inner.visit_bot() { return false; }
fn write_escaped_char(ch: char);
}
-impl Writer : EscapedCharWriter {
+impl EscapedCharWriter for Writer {
fn write_escaped_char(ch: char) {
match ch {
'\t' => self.write_str("\\t"),
fn write_repr(writer: @Writer);
}
-impl () : Repr {
+impl Repr for () {
fn write_repr(writer: @Writer) { writer.write_str("()"); }
}
-impl bool : Repr {
+impl Repr for bool {
fn write_repr(writer: @Writer) {
writer.write_str(if self { "true" } else { "false" })
}
}
-impl int : Repr {
+impl Repr for int {
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); }
}
-impl i16 : Repr {
+impl Repr for i16 {
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); }
}
-impl i64 : Repr {
+impl Repr for i64 {
// FIXME #4424: This can lose precision.
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); }
}
-impl u8 : Repr {
+impl Repr for u8 {
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); }
}
-impl u32 : Repr {
+impl Repr for u32 {
fn write_repr(writer: @Writer) { writer.write_uint(self as uint); }
}
-impl u64 : Repr {
+impl Repr for u64 {
// FIXME #4424: This can lose precision.
fn write_repr(writer: @Writer) { writer.write_uint(self as uint); }
}
-impl float : Repr {
+impl Repr for float {
// FIXME #4423: This mallocs.
fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); }
}
-impl f32 : Repr {
+impl Repr for f32 {
// FIXME #4423 This mallocs.
fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); }
}
-impl f64 : Repr {
+impl Repr for f64 {
// FIXME #4423: This mallocs.
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); }
}
writer: writer }
}
-impl ReprVisitor : MovePtr {
+impl MovePtr for ReprVisitor {
#[inline(always)]
fn move_ptr(adjustment: fn(*c_void) -> *c_void) {
self.ptr = adjustment(self.ptr);
}
-impl ReprVisitor : TyVisitor {
+impl TyVisitor for ReprVisitor {
fn visit_bot(&self) -> bool {
self.writer.write_str("!");
true
}
}
- impl ProgRes: Program {
+ impl Program for ProgRes {
fn get_id(&mut self) -> pid_t { return self.r.pid; }
fn input(&mut self) -> io::Writer {
io::fd_writer(self.r.in_fd, false)
}
#[cfg(notest)]
-impl &str : Eq {
+impl Eq for &str {
#[inline(always)]
pure fn eq(&self, other: & &self/str) -> bool {
eq_slice((*self), (*other))
}
#[cfg(notest)]
-impl ~str : Eq {
+impl Eq for ~str {
#[inline(always)]
pure fn eq(&self, other: &~str) -> bool {
eq_slice((*self), (*other))
}
#[cfg(notest)]
-impl @str : Eq {
+impl Eq for @str {
#[inline(always)]
pure fn eq(&self, other: &@str) -> bool {
eq_slice((*self), (*other))
}
#[cfg(notest)]
-impl ~str : Ord {
+impl Ord for ~str {
#[inline(always)]
pure fn lt(&self, other: &~str) -> bool { lt((*self), (*other)) }
#[inline(always)]
}
#[cfg(notest)]
-impl &str : Ord {
+impl Ord for &str {
#[inline(always)]
pure fn lt(&self, other: & &self/str) -> bool { lt((*self), (*other)) }
#[inline(always)]
}
#[cfg(notest)]
-impl @str : Ord {
+impl Ord for @str {
#[inline(always)]
pure fn lt(&self, other: &@str) -> bool { lt((*self), (*other)) }
#[inline(always)]
}
/// Extension methods for strings
-impl ~str: Trimmable {
+impl Trimmable for ~str {
/// Returns a string with leading and trailing whitespace removed
#[inline]
pure fn trim() -> ~str { trim(self) }
use ops::Add;
use str::append;
- impl ~str : Add<&str,~str> {
+ impl Add<&str,~str> for ~str {
#[inline(always)]
pure fn add(&self, rhs: & &self/str) -> ~str {
append(copy *self, (*rhs))
}
/// Extension methods for strings
-impl &str: StrSlice {
+impl StrSlice for &str {
/**
* Return true if a predicate matches all characters or if the string
* contains no characters
type rust_task = libc::c_void;
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 {
unsafe {
let ptr_a: (uint, uint) = cast::reinterpret_cast(&(*self));
Failure,
}
-impl TaskResult : Eq {
+impl Eq for TaskResult {
pure fn eq(&self, other: &TaskResult) -> bool {
match ((*self), (*other)) {
(Success, Success) | (Failure, Failure) => true,
pure fn iter_bytes(&self, lsb0: bool, f: Cb);
}
-impl bool: IterBytes {
+impl IterBytes for bool {
#[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
f([
}
}
-impl u8: IterBytes {
+impl IterBytes for u8 {
#[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
f([
}
}
-impl u16: IterBytes {
+impl IterBytes for u16 {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
if lsb0 {
}
}
-impl u32: IterBytes {
+impl IterBytes for u32 {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
if lsb0 {
}
}
-impl u64: IterBytes {
+impl IterBytes for u64 {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
if lsb0 {
}
}
-impl i8: IterBytes {
+impl IterBytes for i8 {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u8).iter_bytes(lsb0, f)
}
}
-impl i16: IterBytes {
+impl IterBytes for i16 {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u16).iter_bytes(lsb0, f)
}
}
-impl i32: IterBytes {
+impl IterBytes for i32 {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u32).iter_bytes(lsb0, f)
}
}
-impl i64: IterBytes {
+impl IterBytes for i64 {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u64).iter_bytes(lsb0, f)
}
}
-impl char: IterBytes {
+impl IterBytes for char {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as u32).iter_bytes(lsb0, f)
}
}
-impl int: IterBytes {
+impl IterBytes for int {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as uint).iter_bytes(lsb0, f)
}
}
-impl<A: IterBytes> &[A]: IterBytes {
+impl<A: IterBytes> IterBytes for &[A] {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
for (*self).each |elt| {
}
}
-impl<A: IterBytes, B: IterBytes> (A,B): IterBytes {
+impl<A: IterBytes, B: IterBytes> IterBytes for (A,B) {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
match *self {
}
}
-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)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
match *self {
a
}
-impl<A: IterBytes> ~[A]: IterBytes {
+impl<A: IterBytes> IterBytes for ~[A] {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
borrow(*self).iter_bytes(lsb0, f)
}
}
-impl<A: IterBytes> @[A]: IterBytes {
+impl<A: IterBytes> IterBytes for @[A] {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
borrow(*self).iter_bytes(lsb0, f)
g.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
}
-impl &str: IterBytes {
+impl IterBytes for &str {
#[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
do str::byte_slice(*self) |bytes| {
}
}
-impl ~str: IterBytes {
+impl IterBytes for ~str {
#[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
do str::byte_slice(*self) |bytes| {
}
}
-impl @str: IterBytes {
+impl IterBytes for @str {
#[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
do str::byte_slice(*self) |bytes| {
}
}
-impl<A: IterBytes> Option<A>: IterBytes {
+impl<A: IterBytes> IterBytes for Option<A> {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
match *self {
}
}
-impl<A: IterBytes> &A: IterBytes {
+impl<A: IterBytes> IterBytes for &A {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(**self).iter_bytes(lsb0, f);
}
}
-impl<A: IterBytes> @A: IterBytes {
+impl<A: IterBytes> IterBytes for @A {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(**self).iter_bytes(lsb0, f);
}
}
-impl<A: IterBytes> ~A: IterBytes {
+impl<A: IterBytes> IterBytes for ~A {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(**self).iter_bytes(lsb0, f);
// NB: raw-pointer IterBytes does _not_ dereference
// to the target; it just gives you the pointer-bytes.
-impl<A> *const A: IterBytes {
+impl<A> IterBytes for *const A {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: Cb) {
(*self as uint).iter_bytes(lsb0, f);
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] {
do io::with_bytes_writer |wr| {
for self.iter_bytes(lsb0) |bytes| {
pure fn to_str(&self) -> ~str;
}
-impl bool: ToStr {
+impl ToStr for bool {
#[inline(always)]
pure fn to_str(&self) -> ~str { ::bool::to_str(*self) }
}
-impl (): ToStr {
+impl ToStr for () {
#[inline(always)]
pure fn to_str(&self) -> ~str { ~"()" }
}
-impl ~str: ToStr {
+impl ToStr for ~str {
#[inline(always)]
pure fn to_str(&self) -> ~str { copy *self }
}
-impl &str: ToStr {
+impl ToStr for &str {
#[inline(always)]
pure fn to_str(&self) -> ~str { ::str::from_slice(*self) }
}
-impl @str: ToStr {
+impl ToStr for @str {
#[inline(always)]
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)]
pure fn to_str(&self) -> ~str {
// FIXME(#4760): this causes an llvm assertion
}
}
}
-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)]
pure fn to_str(&self) -> ~str {
// FIXME(#4760): this causes an llvm assertion
}
}
-impl<A: ToStr> ~[A]: ToStr {
+impl<A: ToStr> ToStr for ~[A] {
#[inline(always)]
pure fn to_str(&self) -> ~str {
unsafe {
}
}
-impl<A: ToStr> @A: ToStr {
+impl<A: ToStr> ToStr for @A {
#[inline(always)]
pure fn to_str(&self) -> ~str { ~"@" + (**self).to_str() }
}
-impl<A: ToStr> ~A: ToStr {
+impl<A: ToStr> ToStr for ~A {
#[inline(always)]
pure fn to_str(&self) -> ~str { ~"~" + (**self).to_str() }
}
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
#[inline(always)]
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)]
pure fn first_ref(&self) -> &self/T {
match *self {
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)]
fn zip(&self) -> ~[(A, B)] {
match *self {
}
}
-impl<A: Copy, B: Copy> (~[A], ~[B]): ExtendedTupleOps<A,B> {
+impl<A: Copy, B: Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
#[inline(always)]
fn zip(&self) -> ~[(A, B)] {
}
#[cfg(notest)]
-impl<A: Eq, B: Eq> (A, B) : Eq {
+impl<A: Eq, B: Eq> Eq for (A, B) {
#[inline(always)]
pure fn eq(&self, other: &(A, B)) -> bool {
match (*self) {
}
#[cfg(notest)]
-impl<A: Ord, B: Ord> (A, B) : Ord {
+impl<A: Ord, B: Ord> Ord for (A, B) {
#[inline(always)]
pure fn lt(&self, other: &(A, B)) -> bool {
match (*self) {
}
#[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)]
pure fn eq(&self, other: &(A, B, C)) -> bool {
match (*self) {
}
#[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)]
pure fn lt(&self, other: &(A, B, C)) -> bool {
match (*self) {
}
#[cfg(notest)]
-impl<T: Eq> &[T] : Eq {
+impl<T: Eq> Eq for &[T] {
#[inline(always)]
pure fn eq(&self, other: & &self/[T]) -> bool { eq((*self), (*other)) }
#[inline(always)]
#[cfg(notest)]
-impl<T: Eq> ~[T] : Eq {
+impl<T: Eq> Eq for ~[T] {
#[inline(always)]
pure fn eq(&self, other: &~[T]) -> bool { eq((*self), (*other)) }
#[inline(always)]
}
#[cfg(notest)]
-impl<T: Eq> @[T] : Eq {
+impl<T: Eq> Eq for @[T] {
#[inline(always)]
pure fn eq(&self, other: &@[T]) -> bool { eq((*self), (*other)) }
#[inline(always)]
pure fn gt<T: Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) }
#[cfg(notest)]
-impl<T: Ord> &[T] : Ord {
+impl<T: Ord> Ord for &[T] {
#[inline(always)]
pure fn lt(&self, other: & &self/[T]) -> bool { lt((*self), (*other)) }
#[inline(always)]
}
#[cfg(notest)]
-impl<T: Ord> ~[T] : Ord {
+impl<T: Ord> Ord for ~[T] {
#[inline(always)]
pure fn lt(&self, other: &~[T]) -> bool { lt((*self), (*other)) }
#[inline(always)]
}
#[cfg(notest)]
-impl<T: Ord> @[T] : Ord {
+impl<T: Ord> Ord for @[T] {
#[inline(always)]
pure fn lt(&self, other: &@[T]) -> bool { lt((*self), (*other)) }
#[inline(always)]
use ops::Add;
use vec::append;
- impl<T: Copy> ~[T] : Add<&[const T],~[T]> {
+ impl<T: Copy> Add<&[const T],~[T]> for ~[T] {
#[inline(always)]
pure fn add(&self, rhs: & &self/[const T]) -> ~[T] {
append(copy *self, (*rhs))
}
}
-impl<T> &[const T]: Container {
+impl<T> Container for &[const T] {
/// Returns true if a vector contains no elements
#[inline]
pure fn is_empty(&self) -> bool { is_empty(*self) }
}
/// 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
#[inline]
pure fn head(&self) -> T { head(*self) }
}
/// Extension methods for vectors
-impl<T> &[T]: ImmutableVector<T> {
+impl<T> ImmutableVector<T> for &[T] {
/// Return a slice that points into another slice.
#[inline]
pure fn view(&self, start: uint, end: uint) -> &self/[T] {
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
*
}
/// 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
* predicate holds.
fn partition(self, f: pure fn(&T) -> bool) -> (~[T], ~[T]);
}
-impl<T> ~[T]: OwnedVector<T> {
+impl<T> OwnedVector<T> for ~[T] {
#[inline]
fn push(&mut self, t: T) {
push(self, t);
}
}
-impl<T> ~[T]: Mutable {
+impl<T> Mutable for ~[T] {
/// Clear the vector, removing all values.
fn clear(&mut self) { self.truncate(0) }
}
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]
fn push_all(&mut self, rhs: &[const T]) {
push_all(self, rhs);
fn dedup(&mut self);
}
-impl<T: Eq> ~[T]: OwnedEqVector<T> {
+impl<T: Eq> OwnedEqVector<T> for ~[T] {
#[inline]
fn dedup(&mut self) {
dedup(self)
// This cannot be used with iter-trait.rs because of the region pointer
// 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) {
// FIXME(#2263)---should be able to call each(self, blk)
for each(*self) |e| {
}
// 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) {
// FIXME(#2263)---should be able to call each(self, blk)
for each(*self) |e| {
}
// 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) {
// FIXME(#2263)---should be able to call each(self, blk)
for each(*self) |e| {
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) {
iter::eachi(self, blk)
}
}
// 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) {
iter::eachi(self, blk)
}
}
// 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) {
iter::eachi(self, blk)
}
}
}
-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 count(&self, x: &A) -> uint { iter::count(self, x) }
}
// 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 count(&self, x: &A) -> uint { iter::count(self, x) }
}
// 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 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] {
iter::filter_to_vec(self, pred)
}
}
// 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] {
iter::filter_to_vec(self, pred)
}
}
// 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] {
iter::filter_to_vec(self, pred)
}
}
}
-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 max(&self) -> A { iter::max(self) }
}
// 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 max(&self) -> A { iter::max(self) }
}
// 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 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) {
let mut i = 0;
while i < self.len() {
}
// 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) {
let mut i = 0;
while i < self.len() {
}
// 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) {
let mut i = 0;
while i < self.len() {
InheritedField // N
}
-impl Family : cmp::Eq {
+impl cmp::Eq for Family {
pure fn eq(&self, other: &Family) -> bool {
((*self) as uint) == ((*other) as uint)
}
type filesearch_impl = {sysroot: Path,
addl_lib_search_paths: ~[Path],
target_triple: ~str};
- impl filesearch_impl: FileSearch {
+ impl FileSearch for filesearch_impl {
fn sysroot() -> Path { /*bad*/copy self.sysroot }
fn lib_search_paths() -> ~[Path] {
let mut paths = /*bad*/copy self.addl_lib_search_paths;
}
}
-impl ast::def_id: tr_intern {
+impl tr_intern for ast::def_id {
fn tr_intern(xcx: extended_decode_ctxt) -> ast::def_id {
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 {
xcx.tr_def_id(self)
}
}
-impl span: tr {
+impl tr for span {
fn tr(xcx: extended_decode_ctxt) -> span {
xcx.tr_span(self)
}
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) {
did.encode(&self)
}
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 {
let did: ast::def_id = Decodable::decode(&self);
def.tr(xcx)
}
-impl ast::def: tr {
+impl tr for ast::def {
fn tr(xcx: extended_decode_ctxt) -> ast::def {
match self {
ast::def_fn(did, p) => { ast::def_fn(did.tr(xcx), p) }
// ______________________________________________________________________
// Encoding and decoding of adjustment information
-impl ty::AutoAdjustment: tr {
+impl tr for ty::AutoAdjustment {
fn tr(xcx: extended_decode_ctxt) -> ty::AutoAdjustment {
ty::AutoAdjustment {
autoderefs: self.autoderefs,
}
}
-impl ty::AutoRef: tr {
+impl tr for ty::AutoRef {
fn tr(xcx: extended_decode_ctxt) -> ty::AutoRef {
ty::AutoRef {
kind: self.kind,
}
}
-impl ty::Region: tr {
+impl tr for ty::Region {
fn tr(xcx: extended_decode_ctxt) -> ty::Region {
match self {
ty::re_bound(br) => ty::re_bound(br.tr(xcx)),
}
}
-impl ty::bound_region: tr {
+impl tr for ty::bound_region {
fn tr(xcx: extended_decode_ctxt) -> ty::bound_region {
match self {
ty::br_anon(_) | ty::br_named(_) | ty::br_self |
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 {
let fv: freevar_entry = Decodable::decode(&self);
fv.tr(xcx)
}
}
-impl freevar_entry: tr {
+impl tr for freevar_entry {
fn tr(xcx: extended_decode_ctxt) -> freevar_entry {
freevar_entry {
def: self.def.tr(xcx),
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 {
let cvar: moves::CaptureVar = Decodable::decode(&self);
cvar.tr(xcx)
}
}
-impl moves::CaptureVar : tr {
+impl tr for moves::CaptureVar {
fn tr(xcx: extended_decode_ctxt) -> moves::CaptureVar {
moves::CaptureVar {
def: self.def.tr(xcx),
}
}
-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 {
do self.read_rec {
method_map_entry {
}
}
-impl method_origin: tr {
+impl tr for method_origin {
fn tr(xcx: extended_decode_ctxt) -> method_origin {
match self {
typeck::method_static(did) => {
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 {
@self.read_to_vec(|| self.read_vtable_origin(xcx) )
}
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 {
@tyencode::ctxt {diag: self.tcx.sess.diagnostic(),
ds: e::def_to_str,
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) {
do self.emit_opaque {
e::write_type(ecx, self, ty)
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()) {
do self.wr_tag(tag_id as uint) { f() }
}
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 opt_child(tag: c::astencode_tag) -> Option<ebml::Doc> {
reader::maybe_get_doc(self, tag as uint)
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 {
do self.read_opaque |doc| {
tydecode::parse_arg_data(
type fake_session = parse::parse_sess;
#[cfg(test)]
-impl fake_session: fake_ext_ctxt {
+impl fake_ext_ctxt for fake_session {
fn cfg() -> ast::crate_cfg { ~[] }
fn parse_sess() -> parse::parse_sess { self }
fn call_site() -> span {
allow, warn, deny, forbid
}
-impl level : cmp::Eq {
+impl cmp::Eq for level {
pure fn eq(&self, other: &level) -> bool {
((*self) as uint) == ((*other) as uint)
}
enum Variable = uint;
enum LiveNode = uint;
-impl Variable : cmp::Eq {
+impl cmp::Eq for Variable {
pure fn eq(&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 ne(&self, other: &LiveNode) -> bool { *(*self) != *(*other) }
}
ExitNode
}
-impl LiveNodeKind : cmp::Eq {
+impl cmp::Eq for LiveNodeKind {
pure fn eq(&self, other: &LiveNodeKind) -> bool {
match (*self) {
FreeVarNode(e0a) => {
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) }
}
-impl Variable: to_str::ToStr {
+impl to_str::ToStr for Variable {
pure fn to_str(&self) -> ~str { fmt!("v(%u)", **self) }
}
enum LLVM_ABIInfo { LLVM_ABIInfo }
-impl LLVM_ABIInfo: ABIInfo {
+impl ABIInfo for LLVM_ABIInfo {
fn compute_info(&self,
atys: &[TypeRef],
rty: TypeRef,
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 {
((*self) as uint) == ((*other) as uint)
}
enum X86_64_ABIInfo { X86_64_ABIInfo }
-impl X86_64_ABIInfo: ABIInfo {
+impl ABIInfo for X86_64_ABIInfo {
fn compute_info(&self,
atys: &[TypeRef],
rty: TypeRef,
}
}
-impl Dest : cmp::Eq {
+impl cmp::Eq for Dest {
pure fn eq(&self, other: &Dest) -> bool {
match ((*self), (*other)) {
(SaveIn(e0a), SaveIn(e0b)) => e0a == e0b,
cast_other,
}
-impl cast_kind : cmp::Eq {
+impl cmp::Eq for cast_kind {
pure fn eq(&self, other: &cast_kind) -> bool {
match ((*self), (*other)) {
(cast_pointer, cast_pointer) => true,
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) {
to_bytes::iter_bytes_3(&self.cnum, &self.pos, &self.len, lsb0, f);
}
// NB: Do not replace this with #[deriving_eq]. The automatically-derived
// implementation will not recurse through sty and you will get stack
// exhaustion.
-impl intern_key : cmp::Eq {
+impl cmp::Eq for intern_key {
pure fn eq(&self, other: &intern_key) -> bool {
unsafe {
*self.sty == *other.sty && self.o_def_id == other.o_def_id
}
}
-impl intern_key : to_bytes::IterBytes {
+impl to_bytes::IterBytes for intern_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
unsafe {
to_bytes::iter_bytes_2(&*self.sty, &self.o_def_id, lsb0, f);
#[auto_decode]
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: ®ion_variance) -> bool {
match ((*self), (*other)) {
(rv_covariant, rv_covariant) => true,
output: t
}
-impl BareFnTy : to_bytes::IterBytes {
+impl to_bytes::IterBytes for BareFnTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
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) {
to_bytes::iter_bytes_5(&self.purity, &self.sigil, &self.onceness,
&self.region, &self.sig, lsb0, f)
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) {
to_bytes::iter_bytes_2(&self.idx, &self.def_id, lsb0, f)
}
FloatVar(FloatVid)
}
-impl InferTy : to_bytes::IterBytes {
+impl to_bytes::IterBytes for InferTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
TyVar(ref tv) => to_bytes::iter_bytes_2(&0u8, tv, lsb0, f),
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) {
match *self {
ReVar(ref rv) => to_bytes::iter_bytes_2(&0u8, rv, lsb0, f),
}
}
-impl InferRegion : cmp::Eq {
+impl cmp::Eq for InferRegion {
pure fn eq(&self, other: &InferRegion) -> bool {
match ((*self), *other) {
(ReVar(rva), ReVar(rvb)) => {
}
}
-impl param_bound : to_bytes::IterBytes {
+impl to_bytes::IterBytes for param_bound {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
bound_copy => 0u8.iter_bytes(lsb0, f),
}
}
-impl TypeContents : ops::Add<TypeContents,TypeContents> {
+impl ops::Add<TypeContents,TypeContents> for TypeContents {
pure fn add(&self, other: &TypeContents) -> TypeContents {
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 {
TypeContents {bits: self.bits & !other.bits}
}
}
-impl TypeContents : ToStr {
+impl ToStr for TypeContents {
pure fn to_str(&self) -> ~str {
fmt!("TypeContents(%s)", u32::to_str_radix(self.bits, 2))
}
}
}
-impl bound_region : to_bytes::IterBytes {
+impl to_bytes::IterBytes for bound_region {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
ty::br_self => 0u8.iter_bytes(lsb0, f),
}
}
-impl Region : to_bytes::IterBytes {
+impl to_bytes::IterBytes for Region {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
re_bound(ref br) =>
}
}
-impl vstore : to_bytes::IterBytes {
+impl to_bytes::IterBytes for vstore {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
vstore_fixed(ref u) =>
}
}
-impl substs : to_bytes::IterBytes {
+impl to_bytes::IterBytes for substs {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_3(&self.self_r,
&self.self_ty,
}
}
-impl mt : to_bytes::IterBytes {
+impl to_bytes::IterBytes for mt {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.ty,
&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) {
to_bytes::iter_bytes_2(&self.ident,
&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) {
to_bytes::iter_bytes_2(&self.mode,
&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) {
to_bytes::iter_bytes_2(&self.inputs,
&self.output,
}
}
-impl sty : to_bytes::IterBytes {
+impl to_bytes::IterBytes for sty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
ty_nil => 0u8.iter_bytes(lsb0, f),
}
}
-impl mt : cmp::Eq {
+impl cmp::Eq for mt {
pure fn eq(&self, other: &mt) -> bool {
(*self).ty == (*other).ty && (*self).mutbl == (*other).mutbl
}
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 {
match (*self) {
vstore_fixed(e0a) => {
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 {
match (*self) {
re_bound(e0a) => {
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 {
match (*self) {
br_self => {
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: ¶m_bound) -> bool {
match (*self) {
bound_copy => {
-> Result<T,ty::type_err>;
}
-impl ures: then {
+impl then for ures {
fn then<T:Copy>(f: fn() -> Result<T,ty::type_err>)
-> Result<T,ty::type_err> {
self.chain(|_i| f())
fn to_ures() -> ures;
}
-impl<T> cres<T>: ToUres {
+impl<T> ToUres for cres<T> {
fn to_ures() -> ures {
match self {
Ok(ref _v) => Ok(()),
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> {
do self.chain |s| {
if s == t {
ConstrainVarSubReg(RegionVid, Region)
}
-impl Constraint : cmp::Eq {
+impl cmp::Eq for Constraint {
pure fn eq(&self, other: &Constraint) -> bool {
match ((*self), (*other)) {
(ConstrainVarSubVar(v0a, v1a), ConstrainVarSubVar(v0b, v1b)) => {
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) {
match *self {
ConstrainVarSubVar(ref v0, ref v1) =>
b: Region,
}
-impl TwoRegions : cmp::Eq {
+impl cmp::Eq for TwoRegions {
pure fn eq(&self, other: &TwoRegions) -> bool {
(*self).a == (*other).a && (*self).b == (*other).b
}
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) {
to_bytes::iter_bytes_2(&self.a, &self.b, lsb0, f)
}
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 {
self.find(br).get()
}
ch: SharedChan<Msg>
}
-impl Srv: Clone {
+impl Clone for Srv {
fn clone(&self) -> Srv {
Srv {
ch: self.ch.clone()
pub PandocHtml
}
-impl OutputFormat : cmp::Eq {
+impl cmp::Eq for OutputFormat {
pure fn eq(&self, other: &OutputFormat) -> bool {
((*self) as uint) == ((*other) as uint)
}
pub DocPerMod
}
-impl OutputStyle : cmp::Eq {
+impl cmp::Eq for OutputStyle {
pure fn eq(&self, other: &OutputStyle) -> bool {
((*self) as uint) == ((*other) as uint)
}
}
/// Whatever
-impl OmNomNomy: TheShunnedHouse {
+impl TheShunnedHouse for OmNomNomy {
fn dingy_house(&self, _unkempt_yard: int) {
}
fn types(&self) -> ~[TyDoc];
}
-impl ~[Page]: PageUtils {
+impl PageUtils for ~[Page] {
fn mods(&self) -> ~[ModDoc] {
do vec::filter_mapped(*self) |page| {
pure fn item(&self) -> ItemDoc;
}
-impl ItemTag: Item {
+impl Item for ItemTag {
pure fn item(&self) -> ItemDoc {
match self {
&doc::ModTag(ref doc) => copy doc.item,
}
}
-impl SimpleItemDoc: Item {
+impl Item for SimpleItemDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
}
-impl ModDoc: Item {
+impl Item for ModDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
}
-impl NmodDoc: Item {
+impl Item for NmodDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
}
-impl EnumDoc: Item {
+impl Item for EnumDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
}
-impl TraitDoc: Item {
+impl Item for TraitDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
}
-impl ImplDoc: Item {
+impl Item for ImplDoc {
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 sections(&self) -> ~[Section];
}
-impl<A:Item> A: ItemUtils {
+impl<A:Item> ItemUtils for A {
pure fn id(&self) -> AstId {
self.item().id
}
fold_struct: FoldStruct<T>
}
-impl<T: Clone> Fold<T>: Clone {
+impl<T: Clone> Clone for Fold<T> {
fn clone(&self) -> Fold<T> {
Fold {
ctxt: self.ctxt.clone(),
fn write_done(&self);
}
-impl Writer: WriterUtils {
+impl WriterUtils for Writer {
fn write_str(&self, str: ~str) {
(*self)(Write(str));
}
mut path: ~[~str]
}
-impl Ctxt: Clone {
+impl Clone for Ctxt {
fn clone(&self) -> Ctxt {
Ctxt {
srv: self.srv.clone(),
op: T
}
-impl<T: Copy> NominalOp<T>: Clone {
+impl<T: Copy> Clone for NominalOp<T> {
fn clone(&self) -> NominalOp<T> { copy *self }
}
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> {
clone(self)
}
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.
fn clone(&self) -> MutexARC<T> {
// NB: Cloning the underlying mutex is not necessary. Its reference
failed: *mut bool,
}
-impl PoisonOnFail : Drop {
+impl Drop for PoisonOnFail {
fn finalize(&self) {
unsafe {
/* assert !*self.failed;
priv mut chunks: @List<Chunk>,
}
-impl Arena : Drop {
+impl Drop for Arena {
fn finalize(&self) {
unsafe {
destroy_chunk(&self.head);
pure fn to_base64() -> ~str;
}
-impl &[u8]: ToBase64 {
+impl ToBase64 for &[u8] {
pure fn to_base64() -> ~str {
let chars = str::chars(
~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
}
}
-impl &str: ToBase64 {
+impl ToBase64 for &str {
pure fn to_base64() -> ~str {
str::to_bytes(self).to_base64()
}
pure fn from_base64() -> ~[u8];
}
-impl ~[u8]: FromBase64 {
+impl FromBase64 for ~[u8] {
pure fn from_base64() -> ~[u8] {
if self.len() % 4u != 0u { fail!(~"invalid base64 length"); }
}
}
-impl ~str: FromBase64 {
+impl FromBase64 for ~str {
pure fn from_base64() -> ~[u8] {
str::to_bytes(self).from_base64()
}
priv data: ~[BigDigit]
}
-impl BigUint : Eq {
+impl Eq for BigUint {
pure fn eq(&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 le(&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 }
}
-impl BigUint : ToStr {
+impl ToStr for BigUint {
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> {
BigUint::from_str_radix(s, 10)
}
}
-impl BigUint : Shl<uint, BigUint> {
+impl Shl<uint, BigUint> for BigUint {
pure fn shl(&self, rhs: &uint) -> BigUint {
let n_unit = *rhs / BigDigit::bits;
let n_bits = *rhs % BigDigit::bits;
}
}
-impl BigUint : Shr<uint, BigUint> {
+impl Shr<uint, BigUint> for BigUint {
pure fn shr(&self, rhs: &uint) -> BigUint {
let n_unit = *rhs / BigDigit::bits;
let n_bits = *rhs % BigDigit::bits;
}
}
-impl BigUint : Zero {
+impl Zero for BigUint {
static pure fn zero() -> BigUint { BigUint::new(~[]) }
}
-impl BigUint : One {
+impl One for BigUint {
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 {
let new_len = uint::max(self.data.len(), other.data.len());
}
}
-impl BigUint : Sub<BigUint, BigUint> {
+impl Sub<BigUint, BigUint> for BigUint {
pure fn sub(&self, other: &BigUint) -> BigUint {
let new_len = uint::max(self.data.len(), other.data.len());
}
}
-impl BigUint : Mul<BigUint, BigUint> {
+impl Mul<BigUint, BigUint> for BigUint {
pure fn mul(&self, other: &BigUint) -> BigUint {
if self.is_zero() || other.is_zero() { return Zero::zero(); }
}
}
-impl BigUint : Div<BigUint, BigUint> {
+impl Div<BigUint, BigUint> for BigUint {
pure fn div(&self, other: &BigUint) -> BigUint {
let (d, _) = self.divmod(other);
return d;
}
}
-impl BigUint : Modulo<BigUint, BigUint> {
+impl Modulo<BigUint, BigUint> for BigUint {
pure fn modulo(&self, other: &BigUint) -> BigUint {
let (_, m) = self.divmod(other);
return m;
}
}
-impl BigUint : Neg<BigUint> {
+impl Neg<BigUint> for BigUint {
pure fn neg(&self) -> BigUint { fail!() }
}
-impl BigUint : IntConvertible {
+impl IntConvertible for BigUint {
pure fn to_int(&self) -> int {
uint::min(self.to_uint(), int::max_value as uint) as int
}
/// A Sign is a BigInt's composing element.
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 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 le(&self, other: &Sign) -> bool { self.cmp(other) <= 0 }
pure fn ge(&self, other: &Sign) -> bool { self.cmp(other) >= 0 }
priv data: BigUint
}
-impl BigInt : Eq {
+impl Eq for BigInt {
pure fn eq(&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 le(&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 }
}
-impl BigInt : ToStr {
+impl ToStr for BigInt {
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> {
BigInt::from_str_radix(s, 10)
}
}
-impl BigInt : Shl<uint, BigInt> {
+impl Shl<uint, BigInt> for BigInt {
pure fn shl(&self, rhs: &uint) -> BigInt {
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 {
BigInt::from_biguint(self.sign, self.data >> *rhs)
}
}
-impl BigInt : Zero {
+impl Zero for BigInt {
static pub pure fn zero() -> BigInt {
BigInt::from_biguint(Zero, Zero::zero())
}
}
-impl BigInt : One {
+impl One for BigInt {
static pub pure fn one() -> BigInt {
BigInt::from_biguint(Plus, One::one())
}
}
-impl BigInt : Add<BigInt, BigInt> {
+impl Add<BigInt, BigInt> for BigInt {
pure fn add(&self, other: &BigInt) -> BigInt {
match (self.sign, other.sign) {
(Zero, _) => copy *other,
}
}
-impl BigInt : Sub<BigInt, BigInt> {
+impl Sub<BigInt, BigInt> for BigInt {
pure fn sub(&self, other: &BigInt) -> BigInt {
match (self.sign, other.sign) {
(Zero, _) => -other,
}
}
-impl BigInt : Mul<BigInt, BigInt> {
+impl Mul<BigInt, BigInt> for BigInt {
pure fn mul(&self, other: &BigInt) -> BigInt {
match (self.sign, other.sign) {
(Zero, _) | (_, Zero) => Zero::zero(),
}
}
-impl BigInt : Div<BigInt, BigInt> {
+impl Div<BigInt, BigInt> for BigInt {
pure fn div(&self, other: &BigInt) -> BigInt {
let (d, _) = self.divmod(other);
return d;
}
}
-impl BigInt : Modulo<BigInt, BigInt> {
+impl Modulo<BigInt, BigInt> for BigInt {
pure fn modulo(&self, other: &BigInt) -> BigInt {
let (_, m) = self.divmod(other);
return m;
}
}
-impl BigInt : Neg<BigInt> {
+impl Neg<BigInt> for BigInt {
pure fn neg(&self) -> BigInt {
BigInt::from_biguint(self.sign.neg(), copy self.data)
}
}
-impl BigInt : IntConvertible {
+impl IntConvertible for BigInt {
pure fn to_int(&self) -> int {
match self.sign {
Plus => uint::min(self.to_uint(), int::max_value as uint) as int,
}
-impl Bitv: Clone {
+impl Clone for Bitv {
/// Makes a copy of a bitvector
#[inline(always)]
fn clone(&self) -> Bitv {
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 {
self.get(i)
}
dtor: Option<fn@()>,
}
-impl DtorRes : Drop {
+impl Drop for DtorRes {
fn finalize(&self) {
match self.dtor {
option::None => (),
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 {
self.fuzzy_eq_eps(other, &FUZZY_EPSILON)
}
}
}
-impl f32: FuzzyEq<f32> {
+impl FuzzyEq<f32> for f32 {
pure fn fuzzy_eq(&self, other: &f32) -> bool {
self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f32))
}
}
}
-impl f64: FuzzyEq<f64> {
+impl FuzzyEq<f64> for f64 {
pure fn fuzzy_eq(&self, other: &f64) -> bool {
self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f64))
}
struct Complex { r: float, i: float }
- impl Complex: FuzzyEq<float> {
+ impl FuzzyEq<float> for Complex {
pure fn fuzzy_eq(&self, other: &Complex) -> bool {
self.fuzzy_eq_eps(other, &FUZZY_EPSILON)
}
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) {
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 {
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 {
self.port.recv()
}
}
}
-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 {
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 {
self.port.header()
}
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 add_front(t: T) {
let oldlo: uint = self.lo;
// ebml reading
- impl Doc: ops::Index<uint,Doc> {
+ impl ops::Index<uint,Doc> for Doc {
pure fn index(&self, tag: uint) -> Doc {
unsafe {
get_doc(*self, tag)
}
}
- impl Decoder: serialize::Decoder {
+ impl serialize::Decoder for Decoder {
fn read_nil(&self) -> () { () }
fn read_u64(&self) -> u64 { doc_as_u64(self.next_doc(EsU64)) }
}
}
- impl Encoder: ::serialize::Encoder {
+ impl ::serialize::Encoder for Encoder {
fn emit_nil(&self) {}
fn emit_uint(&self, v: uint) {
}
}
-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) {
self.byte_chan.send(CONTINUE.to_vec());
let bytes = self.flattener.flatten(move val);
static fn from_writer(w: Writer) -> Self;
}
- impl json::Decoder: FromReader {
+ impl FromReader for json::Decoder {
static fn from_reader(r: Reader) -> json::Decoder {
match json::from_reader(r) {
Ok(move json) => {
}
}
- impl json::Encoder: FromWriter {
+ impl FromWriter for json::Encoder {
static fn from_writer(w: Writer) -> json::Encoder {
json::Encoder(move w)
}
}
- impl ebml::reader::Decoder: FromReader {
+ impl FromReader for ebml::reader::Decoder {
static fn from_reader(r: Reader) -> ebml::reader::Decoder {
let buf = @r.read_whole_stream();
let doc = ebml::reader::Doc(buf);
}
}
- impl ebml::writer::Encoder: FromWriter {
+ impl FromWriter for ebml::writer::Encoder {
static fn from_writer(w: Writer) -> ebml::writer::Encoder {
ebml::writer::Encoder(move w)
}
// FIXME(#2829) -- futures should not be copyable, because they close
// over fn~'s that have pipes and so forth within!
-impl<A> Future<A> : Drop {
+impl<A> Drop for Future<A> {
fn finalize(&self) {}
}
}
}
-impl BufReader: Reader {
+impl Reader for BufReader {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
self.as_bytes_reader(|r| r.read(bytes, len) )
}
}
}
-impl Json : Eq {
+impl Eq for Json {
pure fn eq(&self, other: &Json) -> bool {
match (self) {
&Number(f0) =>
}
/// Test if two json values are less than one another
-impl Json : Ord {
+impl Ord for Json {
pure fn lt(&self, other: &Json) -> bool {
match (*self) {
Number(f0) => {
pure fn gt(&self, other: &Json) -> bool { (*other).lt(&(*self)) }
}
-impl Error : Eq {
+impl Eq for Error {
pure fn eq(&self, other: &Error) -> bool {
(*self).line == other.line &&
(*self).col == other.col &&
trait ToJson { fn to_json() -> Json; }
-impl Json: ToJson {
+impl ToJson for Json {
fn to_json() -> Json { copy self }
}
-impl @Json: ToJson {
+impl ToJson for @Json {
fn to_json() -> Json { (*self).to_json() }
}
-impl int: ToJson {
+impl ToJson for int {
fn to_json() -> Json { Number(self as float) }
}
-impl i8: ToJson {
+impl ToJson for i8 {
fn to_json() -> Json { Number(self as float) }
}
-impl i16: ToJson {
+impl ToJson for i16 {
fn to_json() -> Json { Number(self as float) }
}
-impl i32: ToJson {
+impl ToJson for i32 {
fn to_json() -> Json { Number(self as float) }
}
-impl i64: ToJson {
+impl ToJson for i64 {
fn to_json() -> Json { Number(self as float) }
}
-impl uint: ToJson {
+impl ToJson for uint {
fn to_json() -> Json { Number(self as float) }
}
-impl u8: ToJson {
+impl ToJson for u8 {
fn to_json() -> Json { Number(self as float) }
}
-impl u16: ToJson {
+impl ToJson for u16 {
fn to_json() -> Json { Number(self as float) }
}
-impl u32: ToJson {
+impl ToJson for u32 {
fn to_json() -> Json { Number(self as float) }
}
-impl u64: ToJson {
+impl ToJson for u64 {
fn to_json() -> Json { Number(self as float) }
}
-impl float: ToJson {
+impl ToJson for float {
fn to_json() -> Json { Number(self) }
}
-impl f32: ToJson {
+impl ToJson for f32 {
fn to_json() -> Json { Number(self as float) }
}
-impl f64: ToJson {
+impl ToJson for f64 {
fn to_json() -> Json { Number(self as float) }
}
-impl (): ToJson {
+impl ToJson for () {
fn to_json() -> Json { Null }
}
-impl bool: ToJson {
+impl ToJson for bool {
fn to_json() -> Json { Boolean(self) }
}
-impl ~str: ToJson {
+impl ToJson for ~str {
fn to_json() -> Json { String(copy self) }
}
-impl @~str: ToJson {
+impl ToJson for @~str {
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 {
match self {
(ref a, ref b) => {
}
}
-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 {
match self {
(ref a, ref b, ref c) => {
}
}
-impl <A: ToJson> ~[A]: ToJson {
+impl<A: ToJson> ToJson for ~[A] {
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 {
let mut d = LinearMap::new();
for self.each |&(key, value)| {
}
}
-impl <A: ToJson> Option<A>: ToJson {
+impl<A: ToJson> ToJson for Option<A> {
fn to_json() -> Json {
match self {
None => Null,
}
}
-impl Json: to_str::ToStr {
+impl to_str::ToStr for Json {
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 {
fmt!("%u:%u: %s", self.line, self.col, *self.msg)
}
unsafe fn as_u32() -> u32;
}
- impl Ipv4Rep: AsUnsafeU32 {
+ impl AsUnsafeU32 for Ipv4Rep {
// this is pretty dastardly, i know
unsafe fn as_u32() -> u32 {
*((ptr::addr_of(&self)) as *u32)
socket_data: @TcpSocketData,
}
-impl TcpSocket : Drop {
+impl Drop for TcpSocket {
fn finalize(&self) {
unsafe {
tear_down_socket_data(self.socket_data)
}
/// 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 {
if len == 0 { return 0 }
let mut count: uint = 0;
}
/// 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]) {
unsafe {
let socket_data_ptr =
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 {
TcpErrData { err_name: self.err_name, err_msg: self.err_msg }
}
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> {
match from_str(s) {
Ok(move url) => Some(url),
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 {
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) {
self.to_str().iter_bytes(lsb0, f)
}
}
}
- 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 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) {
self.count = 0u;
self.chains = chains(initial_capacity);
}
}
- 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 {
unsafe {
// Meh -- this should be safe
}
}
- 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 {
self.get(&k)
}
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
pure fn len(&self) -> uint {
let mut sz = 0u;
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(~[]) }
}
}
}
-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 {
unsafe {
get(*self, key)
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.
///
/// The values are **not** visited in order.
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
pure fn len(&self) -> uint { self.data.len() }
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
fn clear(&mut self) { self.data.truncate(0) }
}
process_msg_block(st);
}
- impl Sha1State: Sha1 {
+ impl Sha1 for Sha1State {
fn reset(&mut self) {
assert (vec::len(self.h) == digest_buf_len);
self.len_low = 0u32;
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
pure fn each(&self, it: fn(&(uint, &self/V)) -> bool) {
for uint::range(0, self.v.len()) |i| {
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
pure fn each_reverse(&self, it: fn(&(uint, &self/V)) -> bool) {
for uint::range_rev(self.v.len(), 0) |i| {
}
}
-impl<V> SmallIntMap<V>: Container {
+impl<V> Container for SmallIntMap<V> {
/// Return the number of elements in the map
pure fn len(&self) -> uint {
let mut sz = 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.
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
pure fn contains_key(&self, key: &uint) -> bool {
self.find(key).is_some()
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); }
}
val: float,
}
- impl CVal: Ord {
+ impl Ord for CVal {
pure fn lt(&self, other: &CVal) -> bool {
unsafe {
let rng = rand::Rng();
struct DVal { val: uint }
- impl DVal: Ord {
+ impl Ord for DVal {
pure fn lt(&self, _x: &DVal) -> bool { true }
pure fn le(&self, _x: &DVal) -> bool { true }
pure fn gt(&self, _x: &DVal) -> bool { true }
}
- impl LVal : Drop {
+ impl Drop for LVal {
fn finalize(&self) {
let x = unsafe { task::local_data::local_data_get(self.key) };
match x {
}
}
- impl LVal: Ord {
+ impl Ord for LVal {
pure fn lt(&self, other: &a/LVal/&self) -> bool {
(*self).val < other.val
}
fn median_abs_dev_pct(self) -> f64;
}
-impl &[f64] : Stats {
+impl Stats for &[f64] {
fn sum(self) -> f64 {
vec::foldl(0.0, self, |p,q| p + *q)
}
type SemAndSignalRelease = SemReleaseGeneric<~[Waitqueue]>;
struct SemReleaseGeneric<Q> { sem: &Sem<Q> }
-impl<Q: Owned> SemReleaseGeneric<Q> : Drop {
+impl<Q: Owned> Drop for SemReleaseGeneric<Q> {
fn finalize(&self) {
self.sem.release();
}
/// A mechanism for atomic-unlock-and-deschedule blocking and signalling.
pub struct Condvar { priv sem: &Sem<~[Waitqueue]> }
-impl Condvar : Drop { fn finalize(&self) {} }
+impl Drop for Condvar { fn finalize(&self) {} }
impl &Condvar {
/**
sem: &Sem<~[Waitqueue]>,
}
- impl SemAndSignalReacquire : Drop {
+ impl Drop for SemAndSignalReacquire {
fn finalize(&self) {
unsafe {
// Needs to succeed, instead of itself dying.
Semaphore { sem: new_sem(count, ()) }
}
-impl Semaphore: Clone {
+impl Clone for Semaphore {
/// Create a new handle to the semaphore.
fn clone(&self) -> Semaphore {
Semaphore { sem: Sem((*self.sem).clone()) }
Mutex { sem: new_sem_and_signal(1, num_condvars) }
}
-impl Mutex: Clone {
+impl Clone for Mutex {
/// Create a new handle to the mutex.
fn clone(&self) -> Mutex { Mutex { sem: Sem((*self.sem).clone()) } }
}
lock: &RWlock,
}
-impl RWlockReleaseRead : Drop {
+impl Drop for RWlockReleaseRead {
fn finalize(&self) {
unsafe {
do task::unkillable {
lock: &RWlock,
}
-impl RWlockReleaseDowngrade : Drop {
+impl Drop for RWlockReleaseDowngrade {
fn finalize(&self) {
unsafe {
do task::unkillable {
/// The "write permission" token used for rwlock.write_downgrade().
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().
pub struct RWlockReadMode { priv lock: &RWlock }
-impl RWlockReadMode : Drop { fn finalize(&self) {} }
+impl Drop for RWlockReadMode { fn finalize(&self) {} }
impl &RWlockWriteMode {
/// Access the pre-downgrade rwlock in write mode.
c: pipes::Chan<()>,
}
- impl SendOnFailure : Drop {
+ impl Drop for SendOnFailure {
fn finalize(&self) {
self.c.send(());
}
}
}
-impl Timespec : Eq {
+impl Eq for Timespec {
pure fn eq(&self, other: &Timespec) -> bool {
self.sec == other.sec && self.nsec == other.nsec
}
pure fn ne(&self, other: &Timespec) -> bool { !self.eq(other) }
}
-impl Timespec : Ord {
+impl Ord for Timespec {
pure fn lt(&self, other: &Timespec) -> bool {
self.sec < other.sec ||
(self.sec == other.sec && self.nsec < other.nsec)
tm_nsec: i32, // nanoseconds
}
-impl Tm : Eq {
+impl Eq for Tm {
pure fn eq(&self, other: &Tm) -> bool {
self.tm_sec == (*other).tm_sec &&
self.tm_min == (*other).tm_min &&
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 {
if self.len() != other.len() {
false
return a_len < b_len;
}
-impl <K: Ord, V> TreeMap<K, V>: Ord {
+impl<K: Ord, V> Ord for TreeMap<K, V> {
#[inline(always)]
pure fn lt(&self, other: &TreeMap<K, V>) -> bool {
lt(self, other)
}
}
-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
pure fn each(&self, f: fn(&(&self/K, &self/V)) -> bool) {
each(&self.root, f)
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
pure fn each_reverse(&self, f: fn(&(&self/K, &self/V)) -> bool) {
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
pure fn len(&self) -> uint { self.length }
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.
fn clear(&mut self) {
self.root = None;
}
}
-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
pure fn contains_key(&self, key: &K) -> bool {
self.find(key).is_some()
priv map: TreeMap<T, ()>
}
-impl <T: Ord> TreeSet<T>: BaseIter<T> {
+impl<T: Ord> BaseIter<T> for TreeSet<T> {
/// Visit all values in order
pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) }
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
-impl <T: Ord> TreeSet<T>: ReverseIter<T> {
+impl<T: Ord> ReverseIter<T> for TreeSet<T> {
/// Visit all values in reverse order
pure fn each_reverse(&self, f: fn(&T) -> bool) {
self.map.each_key_reverse(f)
}
}
-impl <T: Eq Ord> 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 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)]
pure fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map }
#[inline(always)]
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
pure fn len(&self) -> uint { self.map.len() }
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.
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
pure fn contains(&self, value: &T) -> bool {
self.map.contains_key(value)
struct GlobalIoTask(IoTask);
- impl GlobalIoTask: Clone {
+ impl Clone for GlobalIoTask {
fn clone(&self) -> GlobalIoTask {
GlobalIoTask((**self).clone())
}
op_chan: SharedChan<IoTaskMsg>
}
-impl IoTask: Clone {
+impl Clone for IoTask {
fn clone(&self) -> IoTask {
IoTask{
async_handle: self.async_handle,
name: ~str
}
-impl WorkKey: to_bytes::IterBytes {
+impl to_bytes::IterBytes for WorkKey {
#[inline(always)]
pure fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) {
let mut flag = true;
}
}
-impl WorkKey: cmp::Ord {
+impl cmp::Ord for WorkKey {
pure fn lt(&self, other: &WorkKey) -> bool {
self.kind < other.kind ||
(self.kind == other.kind &&
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) {
do self.borrow_mut |p| {
p.declared_inputs.insert(WorkKey::new(kind, name),
ia_never,
}
-impl inline_attr : cmp::Eq {
+impl cmp::Eq for inline_attr {
pure fn eq(&self, other: &inline_attr) -> bool {
((*self) as uint) == ((*other) as uint)
}
cm: @codemap::CodeMap,
}
-impl CodemapT: span_handler {
+impl span_handler for CodemapT {
fn span_fatal(@mut self, sp: span, msg: &str) -> ! {
self.handler.emit(Some((self.cm, sp)), msg, fatal);
fail!();
}
}
-impl HandlerT: handler {
+impl handler for HandlerT {
fn fatal(@mut self, msg: &str) -> ! {
(self.emit)(None, msg, fatal);
fail!();
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) {
do s.emit_struct("Node", 1) {
s.emit_field("id", 0, || s.emit_uint(self.id))
}
}
-impl<D: Decoder> node_id: Decodable {
+impl<D: Decoder> Decodable for node_id {
static fn decode(d: &D) -> Node {
do d.read_struct("Node", 1) {
Node {
mod_path: ~[ast::ident],
trace_mac: bool
}
- impl CtxtRepr: ext_ctxt {
+ impl ext_ctxt for CtxtRepr {
fn codemap(@mut self) -> @CodeMap { self.parse_sess.cm }
fn parse_sess(@mut self) -> parse::parse_sess { self.parse_sess }
fn cfg(@mut self) -> ast::crate_cfg { self.cfg }
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] {
copy self
}
pub fn to_source(cx: ext_ctxt) -> ~str;
}
- impl ast::ident: ToSource {
+ impl ToSource for ast::ident {
fn to_source(cx: ext_ctxt) -> ~str {
copy *cx.parse_sess().interner.get(self)
}
}
- impl @ast::item: ToSource {
+ impl ToSource for @ast::item {
fn to_source(cx: ext_ctxt) -> ~str {
item_to_str(self, cx.parse_sess().interner)
}
}
- impl ~[@ast::item]: ToSource {
+ impl ToSource for ~[@ast::item] {
fn to_source(cx: ext_ctxt) -> ~str {
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 {
ty_to_str(self, cx.parse_sess().interner)
}
}
- impl ~[@ast::Ty]: ToSource {
+ impl ToSource for ~[@ast::Ty] {
fn to_source(cx: ext_ctxt) -> ~str {
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 {
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 {
pprust::expr_to_str(self, cx.parse_sess().interner)
}
// 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] {
cx.parse_tts(self.to_source(cx))
}
}
- impl @ast::item: ToTokens {
+ impl ToTokens for @ast::item {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
- impl ~[@ast::item]: ToTokens {
+ impl ToTokens for ~[@ast::item] {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
- impl @ast::Ty: ToTokens {
+ impl ToTokens for @ast::Ty {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
}
- impl ~[@ast::Ty]: ToTokens {
+ impl ToTokens for ~[@ast::Ty] {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
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] {
cx.parse_tts(self.to_source(cx))
}
}
- impl @ast::expr: ToTokens {
+ impl ToTokens for @ast::expr {
fn to_tokens(cx: ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx))
}
fn parse_tts(s: ~str) -> ~[ast::token_tree];
}
- impl ext_ctxt: ExtParseUtils {
+ impl ExtParseUtils for ext_ctxt {
fn parse_item(s: ~str) -> @ast::item {
let res = parse::parse_item_from_source_str(
fn parse_optional_meta() -> ~[@ast::meta_item];
}
-impl Parser: parser_attr {
+impl parser_attr for Parser {
// Parse attributes that appear before an item
fn parse_outer_attributes() -> ~[ast::attribute] {
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 {
((*self) as uint) == ((*other) as uint)
}
}
}
-impl StringReader: reader {
+impl reader for StringReader {
fn is_eof(@mut self) -> bool { is_eof(self) }
// return the next token. EFFECT: advances the string_reader.
fn next_token(@mut self) -> TokenAndSpan {
}
-impl Token : cmp::Eq {
+impl cmp::Eq for Token {
pure fn eq(&self, other: &Token) -> bool {
match (*self) {
EQ => {
trait me {
fn me() -> uint;
}
-impl uint: me { fn me() -> uint { self } }
+impl me for uint { fn me() -> uint { self } }
fn to(v: uint, f: fn(uint));
}
-impl uint: uint_helpers {
+impl uint_helpers for uint {
#[inline]
fn to(v: uint, f: fn(uint)) {
let mut i = self;
x: ~str
}
-impl Bar : Foo {
+impl Foo for Bar {
#[inline(always)]
fn f(&self) {
io::println((*self).x);
mod unexported {
use super::Fish;
- impl Fish : Eq {
+ impl Eq for Fish {
pure fn eq(&self, _: &Fish) -> bool { true }
pure fn ne(&self, _: &Fish) -> bool { false }
}
pub trait i<T> { }
pub fn f<T>() -> i<T> {
- impl<T> (): i<T> { }
+ impl<T> i<T> for () { }
() as i::<T>
}
fn foo();
}
-impl ~str: foo {
+impl foo for ~str {
fn foo() {}
}
_data: int,
}
-impl<T:Const> arc_destruct<T> : Drop {
+impl<T:Const> Drop for arc_destruct<T> {
fn finalize(&self) {}
}
ctx : int,
}
-impl context_res : Drop {
+impl Drop for context_res {
fn finalize(&self) {}
}
enum maybe<T> { just(T), nothing }
-impl methods<T:copy> for maybe<T> {
+impl copy> for maybe<T> for methods<T {
fn ~[](idx: uint) -> T {
match self {
just(t) { t }
type two_maybes<T> = {a: maybe<T>, b: maybe<T>};
-impl methods<T:copy> for two_maybes<T> {
+impl copy> for two_maybes<T> for methods<T {
fn ~[](idx: uint) -> (T, T) {
(self.a[idx], self.b[idx])
}
-}
\ No newline at end of file
+}
pub fn to_closure<A: Durable Copy>(x: A) -> @fn() -> A {
fn@() -> A { copy x }
-}
\ No newline at end of file
+}
fn to_strz() -> ~str;
}
-impl ~str: to_strz {
+impl to_strz for ~str {
fn to_strz() -> ~str { copy self }
}
use a::to_strz;
-impl bool: to_strz {
+impl to_strz for bool {
fn to_strz() -> ~str { fmt!("%b", self) }
}
fn bar();
}
-impl S: T {
+impl T for S {
fn bar() { }
}
fn use_x<T>();
}
enum y = ();
-impl y:x {
+impl x for y {
fn use_x<T>() {
struct foo { //~ ERROR quux
i: ()
pub enum sooper_sekrit {
pub quux, priv baz
}
-}
\ No newline at end of file
+}
static fn readMaybe(s: ~str) -> Option<Self>;
}
-impl int: read {
+impl read for int {
static fn readMaybe(s: ~str) -> Option<int> {
int::from_str(s)
}
}
-impl bool: read {
+impl read for bool {
static fn readMaybe(s: ~str) -> Option<bool> {
match s {
~"true" => Some(true),
}
pub mod float {
- impl float: ::num::Num2 {
+ impl ::num::Num2 for float {
#[inline]
static pure fn from_int2(n: int) -> float { return n as float; }
}
}
pub mod float {
- impl float: ::num::Num2 {
+ impl ::num::Num2 for float {
static pure fn from_int2(n: int) -> float { return n as float; }
}
}
pub struct A { x: int }
-impl A : Foo { fn f() -> int { 10 } }
-impl A : Bar { fn g() -> int { 20 } }
-impl A : Baz { fn h() -> int { 30 } }
+impl Foo for A { fn f() -> int { 10 } }
+impl Bar for A { fn g() -> int { 20 } }
+impl Baz for A { fn h() -> int { 30 } }
trait Quux: Foo Bar Baz { }
-impl<T: Foo Bar Baz> T: Quux { }
+impl<T: Foo Bar Baz> Quux for T { }
x: int
}
-impl A : Foo {
+impl Foo for A {
fn f() -> int { 10 }
}
im: f64
}
-impl cmplx : ops::Mul<cmplx,cmplx> {
+impl ops::Mul<cmplx,cmplx> for cmplx {
pure fn mul(&self, x: &cmplx) -> cmplx {
cmplx {
re: self.re*(*x).re - self.im*(*x).im,
}
}
-impl cmplx : ops::Add<cmplx,cmplx> {
+impl ops::Add<cmplx,cmplx> for cmplx {
pure fn add(&self, x: &cmplx) -> cmplx {
cmplx {
re: self.re + (*x).re,
struct Devnull();
-impl Devnull: io::Writer {
+impl io::Writer for Devnull {
fn write(&self, _b: &[const u8]) {}
fn seek(&self, _i: int, _s: io::SeekStyle) {}
fn tell(&self) -> uint {0_u}
_l: @nillist,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {}
}
0 => {
} + 5 //~ ERROR unexpected token: `+`
}
-}
\ No newline at end of file
+}
0.02 => {}
_ => {}
};
-}
\ No newline at end of file
+}
trait me {
fn me() -> uint;
}
-impl uint: me { fn me() -> uint { self } } //~ NOTE is `__extensions__::me`
+impl me for uint { fn me() -> uint { self } } //~ NOTE is `__extensions__::me`
fn main() { 1u.me(); } //~ ERROR multiple applicable methods in scope
//~^ NOTE is `ambig_impl_2_lib::__extensions__::me`
//~^^ NOTE candidate #2 derives from the bound `B`
}
-fn main() {}
\ No newline at end of file
+fn main() {}
fn foo() -> int;
}
-impl ~[uint]: foo {
+impl foo for ~[uint] {
fn foo() -> int {1} //~ NOTE candidate #1 is `__extensions__::foo`
}
-impl ~[int]: foo {
+impl foo for ~[int] {
fn foo() -> int {2} //~ NOTE candidate #2 is `__extensions__::foo`
}
let mut x: ~[mut int] = ~[mut 3];
let y: ~[int] = ~[3];
x = y; //~ ERROR values differ in mutability
-}
\ No newline at end of file
+}
let x = 0;
log(debug, x.foo); //~ ERROR attempted access of field
log(debug, x.bar); //~ ERROR attempted access of field
-}
\ No newline at end of file
+}
fn main() {
#[attr]
debug!("hi"); //~ ERROR expected item after attrs
-}
\ No newline at end of file
+}
fn main() {
#[attr]
let _i = 0; //~ ERROR expected item
-}
\ No newline at end of file
+}
fn printme();
}
-impl &mut Foo : Stuff {
+impl Stuff for &mut Foo {
fn printme() {
io::println(fmt!("%d", self.x));
}
pure fn test_mut(&mut self);
}
-impl &[int]: MyIter {
+impl MyIter for &[int] {
pure fn test_mut(&mut self) { }
}
fn bar<T:Copy>();
}
-impl uint: bar {
+impl bar for uint {
fn bar<T:Copy>() {
}
}
// except according to those terms.
fn false() { } //~ ERROR found `false` in ident position
-fn main() { }
\ No newline at end of file
+fn main() { }
// except according to those terms.
fn true() { } //~ ERROR found `true` in ident position
-fn main() { }
\ No newline at end of file
+fn main() { }
struct X { x: () }
-impl X : Drop {
+impl Drop for X {
fn finalize(&self) {
error!("destructor runs");
}
struct X { x: (), }
-impl X : Drop {
+impl Drop for X {
fn finalize(&self) {
error!("destructor runs");
}
struct X { x: (), }
-impl X : Drop {
+impl Drop for X {
fn finalize(&self) {
error!("destructor runs");
}
struct X { x: (), }
-impl X : Drop {
+impl Drop for X {
fn finalize(&self) {
error!("destructor runs");
}
struct X { x: (), }
-impl X : Drop {
+impl Drop for X {
fn finalize(&self) {
error!("destructor runs");
}
struct X { x: (), }
-impl X : Drop {
+impl Drop for X {
fn finalize(&self) {
error!("destructor runs");
}
struct X { x: (), }
-impl X : Drop {
+impl Drop for X {
fn finalize(&self) {
error!("destructor runs");
}
// error-pattern:binary operation + cannot be applied to type `*int`
fn die() -> *int { (0 as *int) + (0 as *int) }
-fn main() { }
\ No newline at end of file
+fn main() { }
loop {
true
}
-}
\ No newline at end of file
+}
for vec::each(~[0]) |_i| { //~ ERROR A for-loop body must return (), but
true
}
-}
\ No newline at end of file
+}
struct r {}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
true
}
while true {
true
}
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
// assigning to various global constants
None = Some(3); //~ ERROR assigning to static item
foo = 6; //~ ERROR assigning to static item
-}
\ No newline at end of file
+}
fn main() {
let x = foo(3);
*x = 4; //~ ERROR assigning to enum content
-}
\ No newline at end of file
+}
p.x.a = 2; //~ ERROR assigning to immutable field
p.y.a = 2; //~ ERROR assigning to const field
p.z.a = 2;
-}
\ No newline at end of file
+}
x: &[&str],
}
-impl defer : Drop {
+impl Drop for defer {
fn finalize(&self) {
error!("%?", self.x);
}
fn main() {
let mut f = Foo { n: LinearSet::new() };
bar(&mut f);
-}
\ No newline at end of file
+}
enum foo = ~uint;
-impl foo : Add<foo, foo> {
+impl Add<foo, foo> for foo {
pure fn add(f: &foo) -> foo {
foo(~(**self + **(*f)))
}
y: int,
}
-impl Point : ops::Add<int,int> {
+impl ops::Add<int,int> for Point {
pure fn add(&self, z: &int) -> int {
self.x + self.y + (*z)
}
pure fn purem();
}
-impl point: methods {
+impl methods for point {
fn impurem() {
}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
*q += 1;
io::println(fmt!("*r = %u", *r));
io::println(fmt!("*r = %u", *s));
-}
\ No newline at end of file
+}
fn main() {
assert has_mut_vec(@~[mut 1, 2, 3]) == 6;
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
i: (),
}
-impl noncopyable : Drop {
+impl Drop for noncopyable {
fn finalize(&self) {
error!("dropped");
}
// except according to those terms.
// error-pattern: cast from nil: `()` as `u32`
-fn main() { let u = (assert true) as u32; }
\ No newline at end of file
+fn main() { let u = (assert true) as u32; }
// except according to those terms.
// error-pattern: cast to nil: `u32` as `()`
-fn main() { let u = 0u32 as (); }
\ No newline at end of file
+fn main() { let u = 0u32 as (); }
}
}
-impl cat : noisy {
+impl noisy for cat {
fn speak() { self.meow(); }
}
meows: uint,
}
-impl cat : animal {
+impl animal for cat {
}
fn cat(in_x : uint) -> cat {
fn main() {
let nyan = cat(0u);
-}
\ No newline at end of file
+}
}
- fn main() { }
\ No newline at end of file
+ fn main() { }
mutate(y); //~ ERROR values differ in mutability
}
-fn main() {}
\ No newline at end of file
+fn main() {}
const b: int = a;
fn main() {
-}
\ No newline at end of file
+}
i: int,
}
-impl foo : Drop {
+impl Drop for foo {
fn finalize(&self) {}
}
x: ~str,
}
-impl X : Drop {
+impl Drop for X {
fn finalize(&self) {
error!("value: %s", self.x);
}
type Foo = @[u8];
-impl Foo : Drop { //~ ERROR the Drop trait may only be implemented
+impl Drop for Foo { //~ ERROR the Drop trait may only be implemented
//~^ ERROR cannot provide an extension implementation
fn finalize(&self) {
io::println("kaboom");
// and the build will fail because main doesn't exist
#[test]
fn main() {
-}
\ No newline at end of file
+}
type t = {};
fn main() {
-}
\ No newline at end of file
+}
x: int
}
-impl Foo : Drop {
+impl Drop for Foo {
fn finalize(&self) {
io::println("kaboom");
}
fn blah();
}
-impl Foo : Drop {
+impl Drop for Foo {
fn finalize(&self) {
io::println("kaboom");
}
}
-impl Foo : Bar {
+impl Bar for Foo {
fn blah() {
self.finalize(); //~ ERROR explicit call to destructor
}
// item attribute. Probably could use a better error message.
#[foo = "bar"]
fmt!("baz")
-fn main() { }
\ No newline at end of file
+fn main() { }
fn main() {
f();
-}
\ No newline at end of file
+}
fn main() {
let a = if true { true };
log(debug, a);
-}
\ No newline at end of file
+}
}
-fn main() {}
\ No newline at end of file
+fn main() {}
// except according to those terms.
// error-pattern:expected
-use foo::{bar}::baz
\ No newline at end of file
+use foo::{bar}::baz
// except according to those terms.
// error-pattern:expected
-use foo::*::bar
\ No newline at end of file
+use foo::*::bar
fn to_option() -> Option<Self>;
}
-impl uint: to_opt {
+impl to_opt for uint {
fn to_option() -> Option<uint> {
Some(self)
}
}
-impl<T:Copy> Option<T>: to_opt {
+impl<T:Copy> to_opt for Option<T> {
fn to_option() -> Option<Option<T>> {
Some(self)
}
enum mlist { cons(int, mlist), nil, }
-fn main() { let a = cons(10, cons(11, nil)); }
\ No newline at end of file
+fn main() { let a = cons(10, cons(11, nil)); }
// error-pattern:no valid digits found for number
fn main() {
log(error, 0b42);
-}
\ No newline at end of file
+}
// error-pattern:no valid digits found for number
fn main() {
log(error, 0bu);
-}
\ No newline at end of file
+}
let myInt: uint = (aFn.theFn)();
assert myInt == 10;
-}
\ No newline at end of file
+}
// except according to those terms.
// error-pattern: main function is not allowed to have type parameters
-fn main<T>() { }
\ No newline at end of file
+fn main<T>() { }
// I use an impl here because it will cause
// the compiler to attempt autoderef and then
// try to resolve the method.
-impl t: to_str_2 {
+impl to_str_2 for t {
fn to_str() -> ~str { ~"t" }
}
fn main() {
foo(None, None);
-}
\ No newline at end of file
+}
fn bind<B>(f: fn(A) -> ~[B]);
}
-impl<A> ~[A]: vec_monad<A> {
+impl<A> vec_monad<A> for ~[A] {
fn bind<B>(f: fn(A) -> ~[B]) {
let mut r = fail!();
for self.each |elt| { r += f(*elt); }
}
// `chan` is not a trait, it's an enum
-impl int: chan { //~ ERROR can only implement trait types
+impl chan for int { //~ ERROR can only implement trait types
fn send(v: int) { fail!() }
}
}
-impl foo : Drop {
+impl Drop for foo {
fn finalize(&self) {
io::println("Goodbye, World!");
*self.x += 1;
fn parse() -> ~[int];
}
-impl parser: parse {
+impl parse for parser {
fn parse() -> ~[int] {
dvec::unwrap(self.tokens) //~ ERROR moving out of immutable field
}
f: int
}
-impl E: A {
+impl A for E {
fn b<F:Copy, G>(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 1 bound, but
}
f: int
}
-impl E: A {
+impl A for E {
fn b<F:Copy Const, G>(_x: F) -> F { fail!() } //~ ERROR in method `b`, type parameter 0 has 2 bounds, but
}
f: int
}
-impl E: A {
+impl A for E {
// n.b. The error message is awful -- see #3404
fn b<F:Copy, G>(_x: G) -> G { fail!() } //~ ERROR method `b` has an incompatible type
}
for not_bool() |_i| {
//~^ ERROR A `for` loop iterator should expect a closure that returns `bool`
};
-}
\ No newline at end of file
+}
x: int,
}
-impl C : Drop {
+impl Drop for C {
fn finalize(&self) {
error!("dropping: %?", self.x);
}
fn main() {
-}
\ No newline at end of file
+}
fn bad (p: *int) {
let _q: &int = p as ∫ //~ ERROR non-scalar cast
-}
\ No newline at end of file
+}
return v0 ^ v1;
}
- impl sipstate: siphash {
+ impl siphash for sipstate {
fn reset() {
self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture
//~^ ERROR unresolved name: k0
};
- impl sipstate: siphash {
+ impl siphash for sipstate {
fn reset() {
self.v0 = k0 ^ 0x736f6d6570736575; //~ ERROR attempted dynamic environment-capture
//~^ ERROR unresolved name: k0
fn main() {
thing(&());
-}
\ No newline at end of file
+}
//~^ ERROR use of undeclared type name
}
- impl<T> foo<T> : Drop {
+ impl<T> Drop for foo<T> {
fn finalize(&self) {}
}
}
fn main() {
let x = function();
error!("%?", x);
-}
\ No newline at end of file
+}
// except according to those terms.
enum thing = uint;
-impl thing : cmp::Ord { //~ ERROR missing method `gt`
+impl cmp::Ord for thing { //~ ERROR missing method `gt`
pure fn lt(&self, other: &thing) -> bool { **self < **other }
pure fn le(&self, other: &thing) -> bool { **self < **other }
pure fn ge(&self, other: &thing) -> bool { **self < **other }
fn main() {
let _p: char = 100; //~ ERROR mismatched types: expected `char` but found
-}
\ No newline at end of file
+}
fn main() {
do 5.times {} //~ ERROR Do-block body must return bool, but returns () here. Perhaps
-}
\ No newline at end of file
+}
fn main() {
for task::spawn { return true; } //~ ERROR A `for` loop iterator should expect a closure that
-}
\ No newline at end of file
+}
fn getChildOption() -> Option<@P>;
}
-impl P: PTrait {
+impl PTrait for P {
fn getChildOption() -> Option<@P> {
const childVal: @P = self.child.get(); //~ ERROR attempt to use a non-constant value in a constant
fail!();
fn add_dynamic(&self, other: &Add) -> int;
}
-impl int: Add {
+impl Add for int {
fn to_int(&self) -> int { *self }
fn add_dynamic(&self, other: &Add) -> int {
self.to_int() + other.to_int() //~ ERROR multiple applicable methods in scope
x: int
}
-impl Thing/*: Mul<int, Thing>*/ { //~ ERROR Look ma, no Mul!
+impl Mul<int, Thing>*/ for Thing/* { //~ ERROR Look ma, no Mul!
pure fn mul(c: &int) -> Thing {
Thing {x: self.x * *c}
}
pub impl Lol: Hahaha { }
-impl Lol: Eq {
+impl Eq for Lol {
pure fn eq(&self, other: &Lol) -> bool { **self != **other }
pure fn ne(&self, other: &Lol) -> bool { **self == **other }
}
} else {
io::println("2 != 4");
}
-}
\ No newline at end of file
+}
mut y: float,
}
-impl Point : ToStr { //~ ERROR implements a method not defined in the trait
+impl ToStr for Point { //~ ERROR implements a method not defined in the trait
static fn new(x: float, y: float) -> Point {
Point { x: x, y: y }
}
fn main() {
let v = &5;
io::println(fmt!("%d", f(v)()));
-}
\ No newline at end of file
+}
fn main () {
f();
-}
\ No newline at end of file
+}
let c = ctr::new(42);
let c2 = ctr::inc(c);
assert *c2 == 5; //~ ERROR can only dereference enums with a single, public variant
-}
\ No newline at end of file
+}
let _ = fn~() { foo(x); }; //~ ERROR value has non-owned type `@uint`
let _ = fn~(copy x) { foo(x); }; //~ ERROR value has non-owned type `@uint`
let _ = fn~(move x) { foo(x); }; //~ ERROR value has non-owned type `@uint`
-}
\ No newline at end of file
+}
trait repeat<A> { fn get() -> A; }
-impl<A:Copy> @A: repeat<A> {
+impl<A:Copy> repeat<A> for @A {
fn get() -> A { *self }
}
repeater(@x)
};
assert 3 == *(y.get()); //~ ERROR reference is not valid
-}
\ No newline at end of file
+}
fn foo(i: &self/int) -> int;
}
-impl<T:Copy> T: foo {
+impl<T:Copy> foo for T {
fn foo(i: &self/int) -> int {*i}
}
}
fn main() {
-}
\ No newline at end of file
+}
x: int
}
- impl S : T {
+ impl T for S {
fn f() { //~ ERROR this method form is deprecated
}
}
trait foo6 { //~ ERROR type, variant, or trait should have a camel case identifier
}
-fn main() { }
\ No newline at end of file
+fn main() { }
x: (),
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {}
}
fn main() {
if (1 == 2) { forever(); }
-}
\ No newline at end of file
+}
two_args(x, y); //~ ERROR (values differ in mutability)
two_args(a, b); //~ ERROR (values differ in mutability)
-}
\ No newline at end of file
+}
x: int
}
-impl int : MyEq {
+impl MyEq for int {
pure fn eq(&self, other: &int) -> bool { *self == *other }
}
fn main() {
assert mod_file_aux::bar() == 10; //~ ERROR unresolved name
-}
\ No newline at end of file
+}
fn main() {
assert mod_file_aux::bar() == 10;
-}
\ No newline at end of file
+}
fn main() {
assert m::foo() == 10;
-}
\ No newline at end of file
+}
touch(&x[0]); //~ ERROR use of partially moved value: `x`
}
-fn main() {}
\ No newline at end of file
+fn main() {}
mod foo {
fn main() { //~ ERROR multiple 'main' functions
}
-}
\ No newline at end of file
+}
y: int
}
-impl S: Cmp, ToStr { //~ ERROR: expected `{` but found `,`
+impl Cmp, ToStr for S { //~ ERROR: expected `{` but found `,`
fn eq(&&other: S) { false }
fn to_str(&self) -> ~str { ~"hi" }
}
_x: Port<()>,
}
- impl foo : Drop {
+ impl Drop for foo {
fn finalize(&self) {}
}
x:int,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {}
}
x:@mut int,
}
-impl r2 : Drop {
+impl Drop for r2 {
fn finalize(&self) {}
}
x: int,
}
-impl bar : Drop {
+impl Drop for bar {
fn finalize(&self) {}
}
// except according to those terms.
fn foo(x) { //~ ERROR expected `:` but found `)`
-}
\ No newline at end of file
+}
let_in(3, fn&(i) { assert i == 3u; });
//~^ ERROR expected `int` but found `uint`
-}
\ No newline at end of file
+}
i: @mut int,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
*(self.i) = *(self.i) + 1;
}
fn main() {
// we used to print foo<int>:
bar(Some(3u)); //~ ERROR mismatched types: expected `foo`
-}
\ No newline at end of file
+}
fn main() {
let _x = private_variant_1::super_sekrit::baz; //~ ERROR baz is private
-}
\ No newline at end of file
+}
pure fn modify_in_box_rec(sum: @{mut f: int});
}
-impl int: modify_in_box_rec {
+impl modify_in_box_rec for int {
pure fn modify_in_box_rec(sum: @{mut f: int}) {
sum.f = self; //~ ERROR assigning to mutable field prohibited in pure context
}
type fake_session = parse::parse_sess;
-impl fake_session: fake_ext_ctxt {
+impl fake_ext_ctxt for fake_session {
fn cfg() -> ast::crate_cfg { ~[] }
fn parse_sess() -> parse::parse_sess { self }
fn call_site() -> span {
type fake_session = parse::parse_sess;
-impl fake_session: fake_ext_ctxt {
+impl fake_ext_ctxt for fake_session {
fn cfg() -> ast::crate_cfg { ~[] }
fn parse_sess() -> parse::parse_sess { self }
fn call_site() -> span {
want_foo(b); //~ ERROR expected a record with field `a`
}
-fn main() {}
\ No newline at end of file
+fn main() {}
x: int,
}
-impl my_resource : Drop {
+impl Drop for my_resource {
fn finalize(&self) {
log(error, self.x);
}
}
fn main() {
-}
\ No newline at end of file
+}
fn get() -> int;
}
-impl &int: deref {
+impl deref for &int {
fn get() -> int {
*self
}
const c_y: &static/int = &22;
fn main() {
-}
\ No newline at end of file
+}
x5(&foo/uint) //~ ERROR named regions other than `self` are not allowed as part of a type declaration
}
-fn main() {}
\ No newline at end of file
+fn main() {}
x: &uint,
}
-impl yes0 : Drop {
+impl Drop for yes0 {
fn finalize(&self) {}
}
x: &self/uint,
}
-impl yes1 : Drop {
+impl Drop for yes1 {
fn finalize(&self) {}
}
x: &foo/uint, //~ ERROR named regions other than `self` are not allowed as part of a type declaration
}
-impl yes2 : Drop {
+impl Drop for yes2 {
fn finalize(&self) {}
}
x: &foo/uint //~ ERROR named regions other than `self` are not allowed as part of a type declaration
};
-fn main() {}
\ No newline at end of file
+fn main() {}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
}
fn main() {
-}
\ No newline at end of file
+}
fn set_f_bad(b: @b);
}
-impl c: set_f {
+impl set_f for c {
fn set_f_ok(b: @b/&self) {
self.f = b;
}
fn set_foo(f: foo);
}
-impl with_foo: set_foo_foo {
+impl set_foo_foo for with_foo {
fn set_foo(f: foo) {
self.f = f; //~ ERROR mismatched types: expected `@foo/&self` but found `@foo/&`
}
fn set_foo(f: bar);
}
-impl with_bar: set_foo_bar {
+impl set_foo_bar for with_bar {
fn set_foo(f: bar) {
self.f = f;
}
fn take_foo(x: foo/&) {} //~ ERROR no region bound is allowed on `foo`
fn main() {
-}
\ No newline at end of file
+}
});
}
-fn main() {}
\ No newline at end of file
+fn main() {}
});
}
-fn main() {}
\ No newline at end of file
+fn main() {}
}
}
-fn main() {}
\ No newline at end of file
+fn main() {}
}
}
-fn main() {}
\ No newline at end of file
+fn main() {}
type has_ctxt = { c: &ctxt };
-impl has_ctxt: get_ctxt {
+impl get_ctxt for has_ctxt {
// Here an error occurs because we used `&self` but
// the definition used `&`:
type has_ctxt = { c: &ctxt };
-impl has_ctxt: get_ctxt {
+impl get_ctxt for has_ctxt {
fn get_ctxt() -> &self/ctxt { self.c }
}
}
}
-fn main() {}
\ No newline at end of file
+fn main() {}
}
-impl Foo : Drop {
+impl Drop for Foo {
fn finalize(&self) {
io::println("Goodbye!");
}
fn main() {
let be = 0;
//~^ ERROR `be` is a reserved keyword
-}
\ No newline at end of file
+}
fn plus(++x: Self) -> Self;
}
-impl int: add {
+impl add for int {
fn plus(++x: int) -> int { self + x }
}
fn main() {
trait seq { }
-impl<T> ~[T]: seq<T> { //~ ERROR wrong number of type arguments
+impl<T> seq<T> for ~[T] { //~ ERROR wrong number of type arguments
/* ... */
}
-impl u32: seq<bool> {
+impl seq<bool> for u32 {
/* Treat the integer as a sequence of bits */
}
static fn bar();
}
-impl int: foo {
+impl foo for int {
fn bar() {} //~ ERROR method `bar` is declared as static in its trait, but not in its impl
}
foo: 0,
foo: 0 //~ ERROR field `foo` specified more than once
};
-}
\ No newline at end of file
+}
// No error when type of parameter actually IS @const int
let b = box_impl::<@const int>(@3);
set_box_impl(b, @mut 5);
-}
\ No newline at end of file
+}
let x: @const int = @3; // only way I could find to upcast
let b = box_impl::<@const int>({mut f: x});
set_box_impl(b, @mut 5);
-}
\ No newline at end of file
+}
mut f: T
};
-impl<T:Copy> box_impl<T>: box_trait<T> {
+impl<T:Copy> box_trait<T> for box_impl<T> {
fn get() -> T { return self.f; }
fn set(t: T) { self.f = t; }
}
//~^ ERROR values differ in mutability
set_box_impl(b, @mut 5);
//~^ ERROR values differ in mutability
-}
\ No newline at end of file
+}
trait A { }
-impl int: A {
+impl A for int {
fn foo() { } //~ ERROR method `foo` is not a member of trait `A`
}
-fn main() { }
\ No newline at end of file
+fn main() { }
trait foo {
fn bar(x: uint) -> Self;
}
-impl int: foo {
+impl foo for int {
fn bar() -> int {
//~^ ERROR method `bar` has 0 parameters but the trait has 1
self
fn jbmbo(&self) -> @uint;
}
-impl uint: Mumbo {
+impl Mumbo for uint {
// Cannot have a larger effect than the trait:
fn jumbo(&self, x: @uint) { *self + *x; }
//~^ ERROR expected pure fn but found impure fn
fn jumbo(&self, x: @uint) -> uint;
}
-impl uint: Mumbo {
+impl Mumbo for uint {
// Note: this method def is ok, it is more accepting and
// less effecting than the trait method:
pure fn jumbo(&self, x: @const uint) -> uint { *self + *x }
}
// Can't implement Bar without an impl of Foo
-impl A : Bar {
+impl Bar for A {
fn g() { }
}
iface foo { } //~ ERROR iface
-fn main() {}
\ No newline at end of file
+fn main() {}
// except according to those terms.
trait bar { fn dup() -> Self; fn blah<X>(); }
-impl int: bar { fn dup() -> int { self } fn blah<X>() {} }
-impl uint: bar { fn dup() -> uint { self } fn blah<X>() {} }
+impl bar for int { fn dup() -> int { self } fn blah<X>() {} }
+impl bar for uint { fn dup() -> uint { self } fn blah<X>() {} }
fn main() {
10i.dup::<int>(); //~ ERROR does not take type parameters
trait foo { fn foo(); }
-impl uint: int { fn foo() {} } //~ ERROR trait
+impl int for uint { fn foo() {} } //~ ERROR trait
fn main() {}
identity_u16(a);
//~^ ERROR mismatched types: expected `u16` but found `int`
-}
\ No newline at end of file
+}
//error-pattern:mismatched types
fn main() {
let i: ~int = ~mut 0;
-}
\ No newline at end of file
+}
x: int,
}
-impl Bar : Drop {
+impl Drop for Bar {
fn finalize(&self) {}
}
-impl Bar : Foo {
+impl Foo for Bar {
fn f(&self) {
io::println("hi");
}
b:bool,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {}
}
i: @mut int,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
*(self.i) = *(self.i) + 1;
}
loop{}
// red herring to make sure compilation fails
log(error, 42 == 'c');
-}
\ No newline at end of file
+}
return r;
}
-fn main() {}
\ No newline at end of file
+fn main() {}
fn r(i:int) -> r { r { i: i } }
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {}
}
fn gimme_an_a<A: TraitA>(a: A) -> int;
}
-impl int: TraitB {
+impl TraitB for int {
fn gimme_an_a<A: TraitA>(a: A) -> int {
a.method_a() + self
}
let x = 10;
x; //~ ERROR path statement with no effect
-}
\ No newline at end of file
+}
fn main() {
let i: int = fail!(~"test");
-}
\ No newline at end of file
+}
fn main() {
f();
-}
\ No newline at end of file
+}
fn main() {
fail!(~"test");
-}
\ No newline at end of file
+}
b: int,
}
-impl R : Drop {
+impl Drop for R {
fn finalize(&self) {
let _y = R { b: self.b };
}
fn main() {
task::spawn(|| sleeper() );
task::spawn(|| parent() );
-}
\ No newline at end of file
+}
x:int,
}
-impl and_then_get_big_again : Drop {
+impl Drop for and_then_get_big_again {
fn finalize(&self) {
fn getbig(i: int) {
if i != 0 {
x:int,
}
-impl and_then_get_big_again : Drop {
+impl Drop for and_then_get_big_again {
fn finalize(&self) {
fn getbig(i: int) {
if i != 0 {
x:int,
}
-impl and_then_get_big_again : Drop {
+impl Drop for and_then_get_big_again {
fn finalize(&self) {}
}
// Setting the exit status after the runtime has already
// failed has no effect and the process exits with the
// runtime's exit code
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
os::set_exit_status(50);
}
// 101 is the code the runtime uses on task failure and the value
// compiletest expects run-fail tests to return.
os::set_exit_status(101);
-}
\ No newline at end of file
+}
fn main() {
log(debug, ~"don't optimize me out");
main();
-}
\ No newline at end of file
+}
fn main() {
let a = @0;
assert false;
-}
\ No newline at end of file
+}
v: *int,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
unsafe {
let _v2: ~int = cast::reinterpret_cast(&self.v);
fn foo();
}
-impl ~int: i {
+impl i for ~int {
fn foo() { }
}
fn faily_box(i: @int) -> faily_box { faily_box { i: i } }
-impl faily_box : Drop {
+impl Drop for faily_box {
fn finalize(&self) {
fail!(~"quux");
}
type fake_session = parse::parse_sess;
-impl fake_session: fake_ext_ctxt {
+impl fake_ext_ctxt for fake_session {
fn cfg() -> ast::crate_cfg { ~[] }
fn parse_sess() -> parse::parse_sess { self }
fn call_site() -> span {
debug!("a=%? b=%?", a, b);
assert a == 22u64;
assert b == 44u16;
-}
\ No newline at end of file
+}
debug!("a=%u b=%u", *a as uint, b as uint);
assert *a == x;
assert b == y;
-}
\ No newline at end of file
+}
foo(Some(~22), false);
foo(None, true);
foo(None, false);
-}
\ No newline at end of file
+}
fn iterate(blk: fn(x: &A) -> bool);
}
-impl<A> &[A]: iterable<A> {
+impl<A> iterable<A> for &[A] {
fn iterate(f: fn(x: &A) -> bool) {
for vec::each(self) |e| {
if !f(e) { break; }
}
}
-impl<A> ~[A]: iterable<A> {
+impl<A> iterable<A> for ~[A] {
fn iterate(f: fn(x: &A) -> bool) {
for vec::each(self) |e| {
if !f(e) { break; }
Minus(@Expr, @Expr)
}
-impl Expr : cmp::Eq {
+impl cmp::Eq for Expr {
pure fn eq(&self, other: &Expr) -> bool {
match *self {
Val(e0a) => {
pure fn ne(&self, other: &Expr) -> bool { !(*self).eq(other) }
}
-impl AnEnum : cmp::Eq {
+impl cmp::Eq for AnEnum {
pure fn eq(&self, other: &AnEnum) -> bool {
(*self).v == other.v
}
pure fn ne(&self, other: &AnEnum) -> bool { !(*self).eq(other) }
}
-impl Point : cmp::Eq {
+impl cmp::Eq for Point {
pure fn eq(&self, other: &Point) -> bool {
self.x == other.x && self.y == other.y
}
pure fn ne(&self, other: &Point) -> bool { !(*self).eq(other) }
}
-impl<T:cmp::Eq> Quark<T> : cmp::Eq {
+impl<T:cmp::Eq> cmp::Eq for Quark<T> {
pure fn eq(&self, other: &Quark<T>) -> bool {
match *self {
Top(ref q) => {
pure fn ne(&self, other: &Quark<T>) -> bool { !(*self).eq(other) }
}
-impl CLike : cmp::Eq {
+impl cmp::Eq for CLike {
pure fn eq(&self, other: &CLike) -> bool {
(*self) as int == *other as int
}
fn g(&self);
}
-impl<T:Baz> T : Foo {
+impl<T:Baz> Foo for T {
fn f(&self) {
self.g();
}
}
-impl Bar : Baz {
+impl Baz for Bar {
fn g(&self) {
io::println(self.x.to_str());
}
pure fn test_const(&const self);
}
-impl &[int]: MyIter {
+impl MyIter for &[int] {
pure fn test_imm(&self) { assert self[0] == 1 }
pure fn test_const(&const self) { assert self[0] == 1 }
}
-impl &str: MyIter {
+impl MyIter for &str {
pure fn test_imm(&self) { assert *self == "test" }
pure fn test_const(&const self) { assert *self == "test" }
}
fn push_val(&mut self, +t: T);
}
-impl<T> ~[T]: Pushable<T> {
+impl<T> Pushable<T> for ~[T] {
fn push_val(&mut self, +t: T) {
self.push(move t);
}
v.push_val(2);
v.push_val(3);
assert v == ~[1, 2, 3];
-}
\ No newline at end of file
+}
fn printme();
}
-impl &Foo : Stuff {
+impl Stuff for &Foo {
fn printme() {
io::println(fmt!("%d", self.x));
}
fn double() -> uint;
}
-impl uint: double {
+impl double for uint {
fn double() -> uint { self * 2u }
}
fn double() -> uint;
}
-impl uint: double {
+impl double for uint {
fn double() -> uint { self * 2u }
}
fn double() -> uint;
}
-impl uint: double {
+impl double for uint {
fn double() -> uint { self * 2u }
}
fn double() -> uint;
}
-impl uint: double {
+impl double for uint {
fn double() -> uint { self }
}
-impl @uint: double {
+impl double for @uint {
fn double() -> uint { *self * 2u }
}
fn double() -> uint;
}
-impl @@uint: double {
+impl double for @@uint {
fn double() -> uint { **self * 2u }
}
fn double() -> uint;
}
-impl uint: double {
+impl double for uint {
fn double() -> uint { self * 2u }
}
fn double() -> uint;
}
-impl uint: double {
+impl double for uint {
fn double() -> uint { self * 2u }
}
fn foo(&self) -> ~str;
}
-impl<T: Foo> @T: Foo {
+impl<T: Foo> Foo for @T {
fn foo(&self) -> ~str {
fmt!("@%s", (**self).foo())
}
}
-impl uint: Foo {
+impl Foo for uint {
fn foo(&self) -> ~str {
fmt!("%u", *self)
}
pub fn main() {
let x = @3u;
assert x.foo() == ~"@3";
-}
\ No newline at end of file
+}
assert -2147483648i32 - 1i32 == 2147483647i32;
assert -9223372036854775808i64 - 1i64 == 9223372036854775807i64;
-}
\ No newline at end of file
+}
}
}
-impl p : cmp::Eq {
+impl cmp::Eq for p {
pure fn eq(&self, other: &p) -> bool {
(*self).x == (*other).x && (*self).y == (*other).y
}
fn foo(self);
}
-impl &[int]: Foo {
+impl Foo for &[int] {
fn foo(self) {}
}
pub fn main() {
let x = @[1, 2, 3];
assert sum_slice(x) == 6;
-}
\ No newline at end of file
+}
}
pub fn main() {
-}
\ No newline at end of file
+}
pub fn main() {
assert has_mut_vec(~[1, 2, 3]) == 6;
-}
\ No newline at end of file
+}
fn frob();
}
-impl foo: frob {
+impl frob for foo {
fn frob() {
really_impure(self.bar);
}
assert *b_x == 3;
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
}
-}
\ No newline at end of file
+}
assert *b_x == 3;
assert ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x));
}
-}
\ No newline at end of file
+}
pub fn main() {
switcher(None);
switcher(Some(@3));
-}
\ No newline at end of file
+}
assert *b_x == 3;
assert ptr::addr_of(&(*x)) != ptr::addr_of(&(*b_x));
}
-}
\ No newline at end of file
+}
pub fn main() {
testfn(true);
testfn(false);
-}
\ No newline at end of file
+}
}
};
assert z == 18;
-}
\ No newline at end of file
+}
let x = None;
let y = Some(3);
assert select(&x, &y).get() == 3;
-}
\ No newline at end of file
+}
fn foo();
}
-impl int : Foo {
+impl Foo for int {
fn foo() {
io::println("Hello world!");
}
pub fn main() {
let x = 3;
debug!("&x=%x", ptr::to_uint(&x));
-}
\ No newline at end of file
+}
#[cfg(unix)]
pub fn main() {
-}
\ No newline at end of file
+}
#[cfg(target_family = "unix")]
pub fn main() {
-}
\ No newline at end of file
+}
name: ~str,
}
-impl cat : Drop {
+impl Drop for cat {
#[cat_dropper]
/**
Actually, cats don't always land on their feet when you drop them.
}
}
-impl dog : noisy {
+impl noisy for dog {
fn speak() -> int { self.bark() }
}
name : ~str,
}
-impl cat : noisy {
+impl noisy for cat {
fn speak() -> int { self.meow() as int }
}
name : ~str,
}
-impl cat : noisy {
+impl noisy for cat {
fn speak() { self.meow(); }
}
pub fn main() {
let nyan : noisy = cat(0u, 2, ~"nyan") as noisy;
nyan.speak();
-}
\ No newline at end of file
+}
meows : uint,
}
-impl cat : Drop {
+impl Drop for cat {
fn finalize(&self) {
(self.done)(self.meows);
}
enum cat_type { tuxedo, tabby, tortoiseshell }
-impl cat_type : cmp::Eq {
+impl cmp::Eq for cat_type {
pure fn eq(&self, other: &cat_type) -> bool {
((*self) as uint) == ((*other) as uint)
}
}
}
-impl<T> cat<T>: BaseIter<(int, &T)> {
+impl<T> BaseIter<(int, &T)> for cat<T> {
pure fn each(&self, f: fn(&(int, &self/T)) -> bool) {
let mut n = int::abs(self.meows);
while n > 0 {
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
-impl<T> cat<T>: Container {
+impl<T> Container for cat<T> {
pure fn len(&self) -> uint { self.meows as uint }
pure fn is_empty(&self) -> bool { self.meows == 0 }
}
-impl<T> cat<T>: Mutable {
+impl<T> Mutable for cat<T> {
fn clear(&mut self) {}
}
-impl<T> cat<T>: Map<int, T> {
+impl<T> Map<int, T> for cat<T> {
pure fn contains_key(&self, k: &int) -> bool { *k <= self.meows }
pure fn each_key(&self, f: fn(v: &int) -> bool) {
}
}
-impl cat : noisy {
+impl noisy for cat {
fn speak() { self.meow(); }
assert(!nyan.eat());
for uint::range(1u, 10u) |_i| { nyan.speak(); };
assert(nyan.eat());
-}
\ No newline at end of file
+}
}
}
-impl cat : noisy {
+impl noisy for cat {
fn speak() { self.meow(); }
}
}
}
-impl cat: ToStr {
+impl ToStr for cat {
pure fn to_str(&self) -> ~str { copy self.name }
}
pub fn main() {
let nyan = cat(~"nyan");
-}
\ No newline at end of file
+}
assert(!nyan.eat());
for uint::range(1u, 10u) |_i| { nyan.speak(); };
assert(nyan.eat());
-}
\ No newline at end of file
+}
assert(!nyan.eat());
for uint::range(1u, 10u) |_i| { nyan.speak(); };
assert(nyan.eat());
-}
\ No newline at end of file
+}
let z : @{a:int, b:int} = @{ a : 10, b : 12};
let p = task::_spawn(bind f(z));
task::join_id(p);
-}
\ No newline at end of file
+}
fn reverse(&self);
}
-impl &mut [uint] : Reverser {
+impl Reverser for &mut [uint] {
fn reverse(&self) {
vec::reverse(*self);
}
trait X {}
-impl<A:Copy> A : X {}
+impl<A:Copy> X for A {}
struct S {
x: int,
drop {}
}
-impl S : X {}
+impl X for S {}
pub fn main(){}
pub fn main() {
enum x { foo }
- impl x : ::core::cmp::Eq {
+ impl ::core::cmp::Eq for x {
pure fn eq(&self, other: &x) -> bool {
(*self) as int == (*other) as int
}
assert !cmp(Some(3), Some(4));
assert cmp(Some(3), Some(3));
assert cmp(None, None);
-}
\ No newline at end of file
+}
bar: uint
}
- impl Foo: Fooable {
+ impl Fooable for Foo {
#[cfg(bogus)]
static fn what() { }
pub fn main() {
assert b == 3;
-}
\ No newline at end of file
+}
pub fn main() {
assert foopy == f;
assert f == s.f;
-}
\ No newline at end of file
+}
pub fn main() {
assert (b.f)() == 0xca7f000d;
-}
\ No newline at end of file
+}
pub fn main() {
assert toplevel_mod == -1;
-}
\ No newline at end of file
+}
struct foo { a: int, b: int, c: int }
-impl foo : cmp::Eq {
+impl cmp::Eq for foo {
pure fn eq(&self, other: &foo) -> bool {
(*self).a == (*other).a &&
(*self).b == (*other).b &&
let w = @foo{ mut z: || nop() };
let x : fn@() = || nop_foo(w);
w.z = x;
-}
\ No newline at end of file
+}
let w = @foo{ z: || nop() };
let x : fn@() = || nop_foo(~[], w);
w.z = x;
-}
\ No newline at end of file
+}
let w = @foo { mut z: || nop() };
let x : fn@() = || nop_foo(o(), w);
w.z = x;
-}
\ No newline at end of file
+}
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
];
-}
\ No newline at end of file
+}
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
];
-}
\ No newline at end of file
+}
x: int
}
-impl A : Foo {
+impl Foo for A {
fn g() {
io::println("Goodbye!");
}
pub fn main() {
for f { }
do d { }
-}
\ No newline at end of file
+}
}
pub fn main() {
-}
\ No newline at end of file
+}
x: T
}
-impl<T> S<T> : ::core::ops::Drop {
+impl<T> ::core::ops::Drop for S<T> {
fn finalize(&self) {
io::println("bye");
}
x: int
}
-impl Foo : Drop {
+impl Drop for Foo {
fn finalize(&self) {
io::println("bye");
}
trait thing<A> {
fn foo() -> Option<A>;
}
-impl<A> int: thing<A> {
+impl<A> thing<A> for int {
fn foo() -> Option<A> { None }
}
fn foo_func<A, B: thing<A>>(x: B) -> Option<A> { x.foo() }
enum chan { chan_t, }
-impl chan : cmp::Eq {
+impl cmp::Eq for chan {
pure fn eq(&self, other: &chan) -> bool {
((*self) as uint) == ((*other) as uint)
}
x: int
}
-impl S : Foo {
+impl Foo for S {
fn f(@self) {
assert self.x == 3;
}
fn read_bytes(&self, len: uint);
}
-impl<T: Reader> T : ReaderUtil {
+impl<T: Reader> ReaderUtil for T {
fn read_bytes(&self, len: uint) {
let mut count = self.read(&mut [0], len);
y: int
}
-impl S: Reader {
+impl Reader for S {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
0
}
fn read_bytes(&self, len: uint);
}
-impl<T: Reader> T : ReaderUtil {
+impl<T: Reader> ReaderUtil for T {
fn read_bytes(&self, len: uint) {
let mut count = self.read(&mut [0], len);
y: int
}
-impl S: Reader {
+impl Reader for S {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
0
}
fn read_bytes(len: uint);
}
-impl<T: Reader> T : ReaderUtil {
+impl<T: Reader> ReaderUtil for T {
fn read_bytes(len: uint) {
let mut count = self.read(&mut [0], len);
y: int
}
-impl S: Reader {
+impl Reader for S {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
0
}
fn read_bytes(len: uint);
}
-impl<T: Reader> T : ReaderUtil {
+impl<T: Reader> ReaderUtil for T {
fn read_bytes(len: uint) {
let mut count = self.read(&mut [0], len);
y: int
}
-impl S: Reader {
+impl Reader for S {
fn read(bytes: &mut [u8], len: uint) -> uint {
0
}
x: int
}
-impl S : Foo {
+impl Foo for S {
fn f(&self) {
assert self.x == 3;
}
x: int
}
-impl S : Foo {
+impl Foo for S {
fn f(~self) {
assert self.x == 3;
}
}
trait Nus { fn f(&self); }
-impl thing: Nus { fn f(&self) {} }
+impl Nus for thing { fn f(&self) {} }
pub fn main() {
// not exported
enum t { t1, t2, }
- impl t : cmp::Eq {
+ impl cmp::Eq for t {
pure fn eq(&self, other: &t) -> bool {
((*self) as uint) == ((*other) as uint)
}
enum mood { happy, sad, }
-impl mood : cmp::Eq {
+impl cmp::Eq for mood {
pure fn eq(&self, other: &mood) -> bool {
((*self) as uint) == ((*other) as uint)
}
enum mood { happy, sad, }
-impl mood : cmp::Eq {
+impl cmp::Eq for mood {
pure fn eq(&self, other: &mood) -> bool {
((*self) as uint) == ((*other) as uint)
}
}
pub fn main() {
-}
\ No newline at end of file
+}
assert add(3)(4) == 7;
let add3 : fn(int)->int = add(3);
assert add3(4) == 7;
-}
\ No newline at end of file
+}
let h = f;
g(h, &mut called);
assert called == true;
-}
\ No newline at end of file
+}
pub fn main() {
likes_block(bare);
-}
\ No newline at end of file
+}
pub fn main() {
likes_shared(bare);
-}
\ No newline at end of file
+}
pub fn main() {
f();
-}
\ No newline at end of file
+}
// Bare functions should just be a pointer
assert sys::rustrt::size_of::<fn()>() ==
sys::rustrt::size_of::<int>();
-}
\ No newline at end of file
+}
pub fn main() {
fn f() {}
let i: r = r {field: f};
-}
\ No newline at end of file
+}
let data: *int = cast::transmute(data);
assert *data == 100;
}
-}
\ No newline at end of file
+}
x: int
}
-impl S : Foo<int> {
+impl Foo<int> for S {
fn get() -> int {
self.x
}
}
pub fn main() {
-}
\ No newline at end of file
+}
fn foo() -> uint;
}
-impl<T> ~[const T]: foo {
+impl<T> foo for ~[const T] {
fn foo() -> uint { vec::len(self) }
}
loop { }
}
-pub fn main() { let t: task = spawn loop(5); join(t); }
\ No newline at end of file
+pub fn main() { let t: task = spawn loop(5); join(t); }
struct Box { x: r }
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
*(self.i) = *(self.i) + 1;
}
assert noise(dog(pug)) == Some(~"woof");
assert noise(rabbit(~"Hilbert", upright)) == None;
assert noise(tiger) == Some(~"roar");
-}
\ No newline at end of file
+}
enum t {
foo(~[t])
}
-pub fn main() {}
\ No newline at end of file
+pub fn main() {}
while s != ~"" {
return;
}
-}
\ No newline at end of file
+}
fn iter(blk: fn(A));
}
-impl<A> fn@(fn(A)): iterable<A> {
+impl<A> iterable<A> for fn@(fn(A)) {
fn iter(blk: fn(A)) { self(blk); }
}
-impl fn@(fn(uint)): iterable<uint> {
+impl iterable<uint> for fn@(fn(uint)) {
fn iter(blk: fn(&&v: uint)) { self( |i| blk(i) ) }
}
}
pub fn main() {
-}
\ No newline at end of file
+}
error!("%?", x);
assert(x == 42);
-}
\ No newline at end of file
+}
}
pub fn main() {
-}
\ No newline at end of file
+}
x: A,
}
-impl<A: Copy> foo<A> : clam<A> {
+impl<A: Copy> clam<A> for foo<A> {
fn chowder(y: A) {
}
}
pub fn main() {
let _c: cloth::fabric = cloth::calico;
-}
\ No newline at end of file
+}
}
-impl socket : Drop {
+impl Drop for socket {
fn finalize(&self) {}
}
fn flat_map_to_vec<B, IB:BaseIter<B>>(op: fn(&A) -> IB) -> ~[B];
}
-impl<A:Copy> BaseIter<A>: FlatMapToVec<A> {
+impl<A:Copy> FlatMapToVec<A> for BaseIter<A> {
fn flat_map_to_vec<B, IB:BaseIter<B>>(op: fn(&A) -> IB) -> ~[B] {
iter::flat_map_to_vec(&self, op)
}
}
-impl Font : Drop {
+impl Drop for Font {
fn finalize(&self) {}
}
// except according to those terms.
trait hax { }
-impl <A> A: hax { }
+impl<A> hax for A { }
fn perform_hax<T: &static>(x: @T) -> hax {
x as hax
b: &mut bool,
}
-impl defer : Drop {
+impl Drop for defer {
fn finalize(&self) {
*(self.b) = true;
}
b: &mut bool,
}
-impl defer : Drop {
+impl Drop for defer {
fn finalize(&self) {
*(self.b) = true;
}
// except according to those terms.
trait hax { }
-impl <A> A: hax { }
+impl<A> hax for A { }
fn perform_hax<T: &static>(x: @T) -> hax {
x as hax
x: int,
}
-impl Kitty : Drop {
+impl Drop for Kitty {
fn finalize(&self) {}
}
empty
}
-impl square: to_str::ToStr {
+impl to_str::ToStr for square {
pure fn to_str(&self) -> ~str {
match *self {
bot => { ~"R" }
fn f();
}
-impl t: it {
+impl it for t {
fn f() { }
}
x: int,
}
-impl cbar : bar<int> {
+impl bar<int> for cbar {
fn get_bar() -> int {
self.x
}
fn to_bytes() -> ~[u8];
}
-impl (): methods {
+impl methods for () {
fn to_bytes() -> ~[u8] {
vec::from_elem(0, 0)
}
}
assert x == 4096;
io::println(fmt!("x = %u", x));
-}
\ No newline at end of file
+}
struct thing { x: int, }
-impl thing : Drop {
+impl Drop for thing {
fn finalize(&self) {}
}
fn double() -> uint;
}
-impl uint: double {
+impl double for uint {
fn double() -> uint { self * 2u }
}
fn foo() { }
let bar: ~fn() = ~foo;
-}
\ No newline at end of file
+}
}
}
-pub fn main() {}
\ No newline at end of file
+pub fn main() {}
}
}
-impl int: Foo {
+impl Foo for int {
fn a() -> int {
3
}
pub fn main(){
let s = Circle(Point { x: 1f, y: 2f }, 3f);
io::println(fmt!("%f", s.area(s)));
-}
\ No newline at end of file
+}
s: int,
}
-impl S: T {
+impl T for S {
fn print(&self) {
io::println(fmt!("%?", self));
}
// Neither of the next two lines should cause an error
let _ = x.stuff();
x.stuff();
-}
\ No newline at end of file
+}
struct Point { mut x: int, mut y: int }
-impl Point: Positioned<int> {
+impl Positioned<int> for Point {
fn SetX(&self, x: int) {
self.x = x;
}
struct Point { mut x: int, mut y: int }
-impl Point: Positioned {
+impl Positioned for Point {
fn SetX(&self, x: int) {
self.x = x;
}
struct Point { mut x: int, mut y: int }
-impl Point: Positioned {
+impl Positioned for Point {
fn SetX(&self, x: int) {
self.x = x;
}
}
assert count == 999_999;
io::println(fmt!("%u", count));
-}
\ No newline at end of file
+}
s => { }
}
}
-}
\ No newline at end of file
+}
b: @mut int,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
*(self.b) += 1;
}
trait repeat<A> { fn get() -> A; }
-impl<A:Copy> @A: repeat<A> {
+impl<A:Copy> repeat<A> for @A {
fn get() -> A { *self }
}
let x = &3;
let y = repeater(@x);
assert *x == *(y.get());
-}
\ No newline at end of file
+}
#[warn(structural_records)];
pub fn main() {
let _foo = {x:5};
-}
\ No newline at end of file
+}
break;
}
assert true;
-}
\ No newline at end of file
+}
is_even = true;
}
assert is_even;
-}
\ No newline at end of file
+}
pub fn main() {
if (1 == 2) { forever(); }
-}
\ No newline at end of file
+}
}
}
-impl Foo : Product {
+impl Product for Foo {
fn product() -> int {
self.x * self.y
}
first._0 = @link(second);
sys.rustrt.gc();
let third: @cell = @{mut c: @nil()};
-}
\ No newline at end of file
+}
pub fn main() {
assert myint32::bits == 32;
assert myint32::min(10, 20) == 10;
-}
\ No newline at end of file
+}
pub fn main() {
assert mod_file_aux::foo() == 10;
-}
\ No newline at end of file
+}
pub fn main() {
assert m::foo() == 10;
-}
\ No newline at end of file
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub type T = f32;
\ No newline at end of file
+pub type T = f32;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub type T = f64;
\ No newline at end of file
+pub type T = f64;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-pub type T = float;
\ No newline at end of file
+pub type T = float;
fn bind<B: Copy>(f: fn(A) -> ~[B]) -> ~[B];
}
-impl<A> ~[A]: vec_monad<A> {
+impl<A> vec_monad<A> for ~[A] {
fn bind<B: Copy>(f: fn(A) -> ~[B]) -> ~[B] {
let mut r = ~[];
for self.each |elt| { r += f(*elt); }
fn bind<B>(f: fn(A) -> Option<B>) -> Option<B>;
}
-impl<A> Option<A>: option_monad<A> {
+impl<A> option_monad<A> for Option<A> {
fn bind<B>(f: fn(A) -> Option<B>) -> Option<B> {
match self {
Some(ref a) => { f(*a) }
fn mk() -> uint;
}
-impl (): ty_ops {
+impl ty_ops for () {
fn mk() -> uint { 22u }
}
mk_nil(())
};
assert fn_env() == 22u;
-}
\ No newline at end of file
+}
fn serialize<S: Serializer>(s: S);
}
-impl int: Serializable {
+impl Serializable for int {
fn serialize<S: Serializer>(_s: S) { }
}
struct F<A> { a: A }
-impl<A: Copy Serializable> F<A>: Serializable {
+impl<A: Copy Serializable> Serializable for F<A> {
fn serialize<S: Serializer>(s: S) {
self.a.serialize(move s);
}
}
-impl io::Writer: Serializer {
+impl Serializer for io::Writer {
}
pub fn main() {
pub fn main() {
getbig(100000);
-}
\ No newline at end of file
+}
pub fn main() {
getbig(10000);
-}
\ No newline at end of file
+}
pub fn main() {
let a = 10000;
getbig(a, a+1, a+2, a+3, a+4, a+5, a+6, a+7, a+8, a+9);
-}
\ No newline at end of file
+}
a38: 10000u64,
a39: 10000u64,
});
-}
\ No newline at end of file
+}
task::try(|| getbig(200) );
sz += 1u;
}
-}
\ No newline at end of file
+}
pub fn main() {
f(fn@() {});
-}
\ No newline at end of file
+}
let z = ~17;
f(z);
g();
-}
\ No newline at end of file
+}
y: int
}
-impl Point : ops::Add<Point,Point> {
+impl ops::Add<Point,Point> for Point {
pure fn add(&self, other: &Point) -> Point {
Point {x: self.x + (*other).x, y: self.y + (*other).y}
}
}
-impl Point : ops::Sub<Point,Point> {
+impl ops::Sub<Point,Point> for Point {
pure fn sub(&self, other: &Point) -> Point {
Point {x: self.x - (*other).x, y: self.y - (*other).y}
}
}
-impl Point : ops::Neg<Point> {
+impl ops::Neg<Point> for Point {
pure fn neg(&self) -> Point {
Point {x: -self.x, y: -self.y}
}
}
-impl Point : ops::Not<Point> {
+impl ops::Not<Point> for Point {
pure fn not(&self) -> Point {
Point {x: !self.x, y: !self.y }
}
}
-impl Point : ops::Index<bool,int> {
+impl ops::Index<bool,int> for Point {
pure fn index(&self, +x: bool) -> int {
if x { self.x } else { self.y }
}
}
-impl Point : cmp::Eq {
+impl cmp::Eq for Point {
pure fn eq(&self, other: &Point) -> bool {
(*self).x == (*other).x && (*self).y == (*other).y
}
}
-impl dtor : Drop {
+impl Drop for dtor {
fn finalize(&self) {
// abuse access to shared mutable state to write this code
*self.x -= 1;
|x| *x + *y
};
assert foo(@22) == 25;
-}
\ No newline at end of file
+}
}
pub fn main() {
-}
\ No newline at end of file
+}
}
// Note: impl on a slice
-impl &int: get {
+impl get for &int {
fn get() -> int {
return *self;
}
}
// Note: impl on a slice
-impl &[int]: sum {
+impl sum for &[int] {
fn sum() -> int {
let mut sum = 0;
for vec::each(self) |e| { sum += *e; }
enum Nil {Nil}
struct Cons<T> {head:int, tail:T}
trait Dot {fn dot(other:self) -> int;}
-impl Nil:Dot {
+impl Dot for Nil {
fn dot(_:Nil) -> int {0}
}
-impl<T:Dot> Cons<T>:Dot {
+impl<T:Dot> Dot for Cons<T> {
fn dot(other:Cons<T>) -> int {
self.head * other.head + self.tail.dot(other.tail)
}
}
-impl<V: TyVisitor movable_ptr> ptr_visit_adaptor<V>: TyVisitor {
+impl<V: TyVisitor movable_ptr> TyVisitor for ptr_visit_adaptor<V> {
fn visit_bot(&self) -> bool {
self.align_to::<()>();
struct Inner<V> { inner: V }
-impl my_visitor: movable_ptr {
+impl movable_ptr for my_visitor {
fn move_ptr(adjustment: fn(*c_void) -> *c_void) {
self.ptr1 = adjustment(self.ptr1);
self.ptr2 = adjustment(self.ptr2);
}
}
-impl my_visitor: TyVisitor {
+impl TyVisitor for my_visitor {
fn visit_bot(&self) -> bool { true }
fn visit_nil(&self) -> bool { true }
use intrinsic::{TyDesc, get_tydesc, visit_tydesc, TyVisitor};
enum my_visitor = @{ mut types: ~[str] };
-impl my_visitor: TyVisitor {
+impl TyVisitor for my_visitor {
fn visit_bot() -> bool {
self.types += ~["bot"];
error!("visited bot type");
}
pub fn main() {
-}
\ No newline at end of file
+}
}
pub fn main() {
-}
\ No newline at end of file
+}
pub fn main() {
assert has_one(&2) == 22;
-}
\ No newline at end of file
+}
pub fn main() {
assert has_two(&20, &2) == 22;
-}
\ No newline at end of file
+}
let g = 21;
let foo = boxed_int { f: &g };
assert with(&foo) == 22;
-}
\ No newline at end of file
+}
let g = 22;
let foo = boxed_int { f: &g };
with(&foo);
-}
\ No newline at end of file
+}
if cond {a} else {b(ptr)}
}
-pub fn main() {}
\ No newline at end of file
+pub fn main() {}
fn get_chowder() -> &self/int;
}
-impl Clam: get_chowder {
+impl get_chowder for Clam {
fn get_chowder() -> &self/int { return self.chowder; }
}
struct HasCtxt { c: &Ctxt }
-impl HasCtxt: get_ctxt {
+impl get_ctxt for HasCtxt {
fn get_ctxt() -> &self/Ctxt {
self.c
}
i: @mut int,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
*(self.i) += 1;
}
v: *int,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
unsafe {
debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x",
v: U,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
unsafe {
let v2: ~int = cast::reinterpret_cast(&self.v.c);
x: *int,
}
-impl R : Drop {
+impl Drop for R {
fn finalize(&self) {
unsafe {
let _v2: ~int = cast::reinterpret_cast(&self.v.c);
i: @@mut int,
}
-impl shrinky_pointer : Drop {
+impl Drop for shrinky_pointer {
fn finalize(&self) {
log(error, ~"Hello!"); **(self.i) -= 1;
}
arg: Arg<T>
}
-impl<T: Copy> finish<T> : Drop {
+impl<T: Copy> Drop for finish<T> {
fn finalize(&self) {
(self.arg.fin)(self.arg.val);
}
}
-impl close_res : Drop {
+impl Drop for close_res {
fn finalize(&self) {
*(self.i) = false;
}
x: int
}
-impl S : MyTrait {
+impl MyTrait for S {
fn f(&self) -> S {
S { x: 3 }
}
f: int,
}
-impl test : Drop {
+impl Drop for test {
fn finalize(&self) {}
}
pub fn main() {
let (_po, ch) = pipes::stream();
ch.send(foo(42, 'c'));
-}
\ No newline at end of file
+}
fn multi(f: fn(uint));
}
-impl uint: uint_utils {
+impl uint_utils for uint {
fn str() -> ~str { uint::str(self) }
fn multi(f: fn(uint)) {
let mut c = 0u;
fn map_<U: Copy>(f: fn(T) -> U) -> ~[U];
}
-impl<T> ~[T]: vec_utils<T> {
+impl<T> vec_utils<T> for ~[T] {
fn length_() -> uint { vec::len(self) }
fn iter_(f: fn(T)) { for self.each |x| { f(*x); } }
fn map_<U: Copy>(f: fn(T) -> U) -> ~[U] {
static fn deserialize(d: &D) -> Self;
}
-impl<D: Deserializer> int: Deserializable<D> {
+impl<D: Deserializer> Deserializable<D> for int {
static fn deserialize(d: &D) -> int {
return d.read_int();
}
struct FromThinAir { dummy: () }
-impl FromThinAir: Deserializer {
+impl Deserializer for FromThinAir {
fn read_int() -> int { 22 }
}
bool_like::select(x1, x2, x1)
}
-impl bool: bool_like {
+impl bool_like for bool {
static fn select<A>(&&b: bool, +x1: A, +x2: A) -> A {
if b { move x1 } else { move x2 }
}
}
-impl int: bool_like {
+impl bool_like for int {
static fn select<A>(&&b: int, +x1: A, +x2: A) -> A {
if b != 0 { move x1 } else { move x2 }
}
}
-impl<A> @[A]: buildable<A> {
+impl<A> buildable<A> for @[A] {
#[inline(always)]
static pure fn build_sized(size: uint,
builder: fn(push: pure fn(+v: A))) -> @[A] {
at_vec::build_sized(size, builder)
}
}
-impl<A> ~[A]: buildable<A> {
+impl<A> buildable<A> for ~[A] {
#[inline(always)]
static pure fn build_sized(size: uint,
builder: fn(push: pure fn(+v: A))) -> ~[A] {
static pub fn foo() -> Self;
}
- impl int : Foo {
+ impl Foo for int {
static pub fn foo() -> int {
3
}
}
- impl uint : Foo {
+ impl Foo for uint {
static pub fn foo() -> uint {
5u
}
x: ~str,
}
-impl foo : Drop {
+impl Drop for foo {
fn finalize(&self) {
error!("%s", self.x);
}
enum foo { large, small, }
-impl foo : cmp::Eq {
+impl cmp::Eq for foo {
pure fn eq(&self, other: &foo) -> bool {
((*self) as uint) == ((*other) as uint)
}
orange = 8 >> 1
}
-impl color : cmp::Eq {
+impl cmp::Eq for color {
pure fn eq(&self, other: &color) -> bool {
((*self) as uint) == ((*other) as uint)
}
// -*- rust -*-
enum colour { red(int, int), green, }
-impl colour : cmp::Eq {
+impl cmp::Eq for colour {
pure fn eq(&self, other: &colour) -> bool {
match *self {
red(a0, b0) => {
tag3(int, u8, char)
}
-impl t : cmp::Eq {
+impl cmp::Eq for t {
pure fn eq(&self, other: &t) -> bool {
match *self {
tag1 => {
pub fn main() {
task::spawn(|| f() );
-}
\ No newline at end of file
+}
ch: Chan<bool>, v: @mut bool,
}
-impl notify : Drop {
+impl Drop for notify {
fn finalize(&self) {
error!("notify: task=%? v=%x unwinding=%b b=%b",
task::get_task(),
assert vec::any(
tests,
|t| t.desc.name.to_str() == ~"shouldnotignore" && !t.desc.ignore);
-}
\ No newline at end of file
+}
type my_connection = ();
type my_connection_factory = ();
-impl (): connection {
+impl connection for () {
fn read() -> int { 43 }
}
-impl my_connection_factory: connection_factory<my_connection> {
+impl connection_factory<my_connection> for my_connection_factory {
fn create() -> my_connection { () }
}
fn to_str() -> ~str;
}
-impl <T: to_str> Option<T>: to_str {
+impl<T: to_str> to_str for Option<T> {
fn to_str() -> ~str {
match self {
None => { ~"none" }
}
}
-impl int: to_str {
+impl to_str for int {
fn to_str() -> ~str { int::str(self) }
}
-impl Tree: to_str {
+impl to_str for Tree {
fn to_str() -> ~str {
let l = self.left, r = self.right;
fmt!("[%s, %s, %s]", self.val.to_str(),
fn g<U>(x: T, y: U) -> (T, U) { (move x, move y) }
}
-impl int: A<int> { }
+impl A<int> for int { }
fn f<T, U, V: A<T>>(i: V, j: T, k: U) -> (T, U) {
i.g(move j, move k)
fn g(x: T) -> T { move x }
}
-impl int: A<int> { }
+impl A<int> for int { }
fn f<T, V: A<T>>(i: V, j: T) -> T {
i.g(move j)
fn g<T>(x: T, y: T) -> (T, T) { (move x, move y) }
}
-impl int: A { }
+impl A for int { }
fn f<T, V: A>(i: V, j: T, k: T) -> (T, T) {
i.g(move j, move k)
fn g(x: uint) -> uint { move x }
}
-impl<T> int: A<T> { }
+impl<T> A<T> for int { }
fn f<T, V: A<T>>(i: V, j: uint) -> uint {
i.g(move j)
fn g() -> int { 10 }
}
-impl int: A { }
+impl A for int { }
fn f<T: A>(i: T) {
assert i.g() == 10;
trait to_str {
fn to_str() -> ~str;
}
-impl int: to_str {
+impl to_str for int {
fn to_str() -> ~str { int::str(self) }
}
-impl ~str: to_str {
+impl to_str for ~str {
fn to_str() -> ~str { copy self }
}
-impl (): to_str {
+impl to_str for () {
fn to_str() -> ~str { ~"()" }
}
trait map<T> {
fn map<U: Copy>(f: fn(T) -> U) -> ~[U];
}
-impl<T> ~[T]: map<T> {
+impl<T> map<T> for ~[T] {
fn map<U: Copy>(f: fn(T) -> U) -> ~[U] {
let mut r = ~[];
for self.each |x| { r += ~[f(*x)]; }
// We want to extend all Foo, Bar, Bazes to Quuxes
pub trait Quux: Foo Bar Baz { }
-impl<T: Foo Bar Baz> T: Quux { }
+impl<T: Foo Bar Baz> Quux for T { }
fn f<T: Quux>(a: &T) {
assert a.f() == 10;
struct A { x: int }
-impl A : Foo { fn f() -> int { 10 } }
-impl A : Bar { fn g() -> int { 20 } }
-impl A : Baz { fn h() -> int { 30 } }
+impl Foo for A { fn f() -> int { 10 } }
+impl Bar for A { fn g() -> int { 20 } }
+impl Baz for A { fn h() -> int { 30 } }
fn f<T: Quux>(a: &T) {
assert a.f() == 10;
// Testing that this impl turns A into a Quux, because
// A is already a Foo Bar Baz
-impl<T: Foo Bar Baz> T: Quux { }
+impl<T: Foo Bar Baz> Quux for T { }
trait Foo { fn f() -> int; }
trait Bar { fn g() -> int; }
struct A { x: int }
-impl A : Foo { fn f() -> int { 10 } }
-impl A : Bar { fn g() -> int { 20 } }
-impl A : Baz { fn h() -> int { 30 } }
+impl Foo for A { fn f() -> int { 10 } }
+impl Bar for A { fn g() -> int { 20 } }
+impl Baz for A { fn h() -> int { 30 } }
fn f<T: Quux>(a: &T) {
assert a.f() == 10;
struct A { x: int }
-impl A : Foo { fn f() -> int { 10 } }
-impl A : Bar { fn g() -> int { 20 } }
+impl Foo for A { fn f() -> int { 10 } }
+impl Bar for A { fn g() -> int { 20 } }
// Call a function on Foo, given a T: Bar
fn gg<T:Bar>(a: &T) -> int {
struct A { x: int }
-impl A : Foo { fn f() -> int { 10 } }
-impl A : Bar { fn g() -> int { 20 } }
-impl A : Baz { fn h() -> int { 30 } }
+impl Foo for A { fn f() -> int { 10 } }
+impl Bar for A { fn g() -> int { 20 } }
+impl Baz for A { fn h() -> int { 30 } }
// Call a function on Foo, given a T: Baz,
// which is inherited via Bar
x: int
}
-impl A : Foo {
+impl Foo for A {
fn f() -> int { 10 }
}
-impl A : Bar {
+impl Bar for A {
fn g() -> int { 20 }
}
x: int
}
-impl A : Foo {
+impl Foo for A {
fn f() -> int { 10 }
}
-impl A : Bar {
+impl Bar for A {
fn g() -> int { 20 }
}
fn g() -> int;
}
-impl aux::A : Bar {
+impl Bar for aux::A {
fn g() -> int { self.f() }
}
struct A { x: int }
-impl A : Foo { fn f() -> int { 10 } }
+impl Foo for A { fn f() -> int { 10 } }
-impl A : Bar {
+impl Bar for A {
// Testing that this impl can call the impl of Foo
fn g() -> int { self.f() }
}
struct S { bogus: () }
-impl S: A { fn a(&self) -> int { 10 } }
-impl S: B { fn b(&self) -> int { 20 } }
-impl S: C { fn c(&self) -> int { 30 } }
-impl S: D { fn d(&self) -> int { 40 } }
+impl A for S { fn a(&self) -> int { 10 } }
+impl B for S { fn b(&self) -> int { 20 } }
+impl C for S { fn c(&self) -> int { 30 } }
+impl D for S { fn d(&self) -> int { 40 } }
fn f<T: D>(x: &T) {
assert x.a() == 10;
pub fn main() {
let value = &S { bogus: () };
f(value);
-}
\ No newline at end of file
+}
struct S { bogus: () }
-impl S: A { fn a(&self) -> int { 10 } }
-impl S: B { fn b(&self) -> int { 20 } }
-impl S: C { fn c(&self) -> int { 30 } }
+impl A for S { fn a(&self) -> int { 10 } }
+impl B for S { fn b(&self) -> int { 20 } }
+impl C for S { fn c(&self) -> int { 30 } }
// Both B and C inherit from A
fn f<T: B C>(x: &T) {
pub fn main() {
f(&S { bogus: () })
-}
\ No newline at end of file
+}
struct S { bogus: () }
-impl S: A { fn a(&self) -> int { 10 } }
-impl S: B { fn b(&self) -> int { 20 } }
-impl S: C { fn c(&self) -> int { 30 } }
+impl A for S { fn a(&self) -> int { 10 } }
+impl B for S { fn b(&self) -> int { 20 } }
+impl C for S { fn c(&self) -> int { 30 } }
// Multiple type params, multiple levels of inheritance
fn f<X: A, Y: B, Z: C>(x: &X, y: &Y, z: &Z) {
pub fn main() {
let s = &S { bogus: () };
f(s, s, s);
-}
\ No newline at end of file
+}
struct MyInt { val: int }
-impl MyInt : Eq {
+impl Eq for MyInt {
pure fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
pure fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
}
struct MyInt { val: int }
-impl MyInt : Add<MyInt, MyInt> {
+impl Add<MyInt, MyInt> for MyInt {
pure fn add(&self, other: &MyInt) -> MyInt { mi(self.val + other.val) }
}
-impl MyInt : Sub<MyInt, MyInt> {
+impl Sub<MyInt, MyInt> for MyInt {
pure fn sub(&self, other: &MyInt) -> MyInt { mi(self.val - other.val) }
}
-impl MyInt : Mul<MyInt, MyInt> {
+impl Mul<MyInt, MyInt> for MyInt {
pure fn mul(&self, other: &MyInt) -> MyInt { mi(self.val * other.val) }
}
-impl MyInt : Eq {
+impl Eq for MyInt {
pure fn eq(&self, other: &MyInt) -> bool { self.val == other.val }
pure fn ne(&self, other: &MyInt) -> bool { !self.eq(other) }
}
x: int
}
-impl S : Foo<S> {
+impl Foo<S> for S {
fn f(&self, x: &S) {
io::println(x.x.to_str());
}
}
-impl S : Bar {
+impl Bar for S {
fn g(&self) {
self.f(self);
}
struct A { x: int }
-impl A : Foo { fn f() -> int { 10 } }
-impl A : Bar { fn g() -> int { 20 } }
+impl Foo for A { fn f() -> int { 10 } }
+impl Bar for A { fn g() -> int { 20 } }
fn ff<T:Foo>(a: &T) -> int {
a.f()
struct S { v: int }
-impl S: MyNum {
+impl MyNum for S {
static fn from_int(i: int) -> S {
S {
v: i
}
}
-impl S: NumExt { }
+impl NumExt for S { }
fn greater_than_one<T:NumExt>() -> T { MyNum::from_int(1) }
struct S { v: int }
-impl S: MyEq { }
+impl MyEq for S { }
-impl S: MyNum {
+impl MyNum for S {
static fn from_int(i: int) -> S {
S {
v: i
}
}
-impl S: NumExt { }
+impl NumExt for S { }
fn greater_than_one<T:NumExt>() -> T { MyNum::from_int(1) }
struct MyInt { val: int }
-impl MyInt : Add<MyInt, MyInt> {
+impl Add<MyInt, MyInt> for MyInt {
pure fn add(other: &MyInt) -> MyInt { mi(self.val + other.val) }
}
struct MyInt { val: int }
-impl MyInt : Panda<MyInt> {
+impl Panda<MyInt> for MyInt {
fn chomp(bamboo: &MyInt) -> MyInt {
mi(self.val + bamboo.val)
}
}
-impl MyInt : Add<MyInt, MyInt> {
+impl Add<MyInt, MyInt> for MyInt {
fn add(other: &MyInt) -> MyInt { self.chomp(other) }
}
mod traits {
pub trait Foo { fn f() -> int; }
- impl int: Foo { fn f() -> int { 10 } }
+ impl Foo for int { fn f() -> int { 10 } }
}
trait Quux: traits::Foo { }
-impl<T: traits::Foo> T: Quux { }
+impl<T: traits::Foo> Quux for T { }
// Foo is not in scope but because Quux is we can still access
// Foo's methods on a Quux bound typaram
pub fn main() {
f(&0)
-}
\ No newline at end of file
+}
struct A { x: int }
-impl A : Foo { fn f() -> int { 10 } }
-impl A : Bar { fn g() -> int { 20 } }
-impl A : Baz { fn h() -> int { 30 } }
+impl Foo for A { fn f() -> int { 10 } }
+impl Bar for A { fn g() -> int { 20 } }
+impl Baz for A { fn h() -> int { 30 } }
impl A : Quux;
fn f<T: Quux Foo Bar Baz>(a: &T) {
x: int
}
-impl A : Foo {
+impl Foo for A {
fn f() -> int {
io::println(~"Today's number is " + self.x.to_str());
return self.x;
fn to_str() -> ~str;
}
-impl int: to_str {
+impl to_str for int {
fn to_str() -> ~str { int::str(self) }
}
-impl<T: to_str> ~[T]: to_str {
+impl<T: to_str> to_str for ~[T] {
fn to_str() -> ~str {
~"[" + str::connect(vec::map(self, |e| e.to_str() ), ~", ") + ~"]"
}
name: int
}
-impl S: Foo {
+impl Foo for S {
fn bar() { }
}
name: 0
};
s.bar();
-}
\ No newline at end of file
+}
Quux
}
-impl Baz: Foo {
+impl Foo for Baz {
}
pub fn main() {
fn purr() -> bool { true }
}
-impl int : Cat {
+impl Cat for int {
fn meow() -> bool {
self.scratch()
}
fn purr() -> bool { true }
}
-impl int : Cat {
+impl Cat for int {
fn meow() -> bool {
self.scratch()
}
}
// pronounced "impl of Ord for int" -- not sold on this yet
-impl int : Ord {
+impl Ord for int {
fn lt(a: &int) -> bool {
self < (*a)
}
i: int,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {}
}
enum Color { cyan, magenta, yellow, black }
-impl Color : Equal {
+impl Equal for Color {
static fn isEq(a: Color, b: Color) -> bool {
match (a, b) {
(cyan, cyan) => { true }
branch(@ColorTree, @ColorTree)
}
-impl ColorTree : Equal {
+impl Equal for ColorTree {
static fn isEq(a: ColorTree, b: ColorTree) -> bool {
match (a, b) {
(leaf(x), leaf(y)) => { Equal::isEq(x, y) }
enum Color { cyan, magenta, yellow, black }
-impl Color : Equal {
+impl Equal for Color {
fn isEq(a: Color) -> bool {
match (self, a) {
(cyan, cyan) => { true }
branch(@ColorTree, @ColorTree)
}
-impl ColorTree : Equal {
+impl Equal for ColorTree {
fn isEq(a: ColorTree) -> bool {
match (self, a) {
(leaf(x), leaf(y)) => { x.isEq(y) }
_ => { }
}
}
-pub fn main() { }
\ No newline at end of file
+pub fn main() { }
// Should drop the previous value of j
j = i;
assert *j == 1;
-}
\ No newline at end of file
+}
let mut i;
i = ~1;
assert *i == 1;
-}
\ No newline at end of file
+}
j: 100
};
assert i.j == 100;
-}
\ No newline at end of file
+}
assert i <= ~100;
assert i > ~99;
assert i >= ~99;
-}
\ No newline at end of file
+}
fn vec() {
~[0];
-}
\ No newline at end of file
+}
let i = ~1;
let j = i;
assert *j == 1;
-}
\ No newline at end of file
+}
pub fn main() {
let i = move ~100;
assert *i == 100;
-}
\ No newline at end of file
+}
let i = ~100;
let j = move i;
assert *j == 100;
-}
\ No newline at end of file
+}
pub fn main() {
let i = ~100;
assert *i == 100;
-}
\ No newline at end of file
+}
pub fn main() {
let ~Foo{a, b} = ~Foo{a: 100, b: 200};
assert a + b == 300;
-}
\ No newline at end of file
+}
pub fn main() {
let i = ~100;
f(move i);
-}
\ No newline at end of file
+}
let mut i = ~100;
f(&mut i);
assert *i == 200;
-}
\ No newline at end of file
+}
f(~100);
let i = ~100;
f(i);
-}
\ No newline at end of file
+}
pub fn main() {
assert f() == ~100;
-}
\ No newline at end of file
+}
pub fn main() {
let i = ~100;
-}
\ No newline at end of file
+}
pub fn main() {
let i = ~100;
log(error, i);
-}
\ No newline at end of file
+}
let j = ~200;
let j = move i;
assert *j == 100;
-}
\ No newline at end of file
+}
let mut i;
i = move ~100;
assert *i == 100;
-}
\ No newline at end of file
+}
let mut j;
j = move i;
assert *j == 100;
-}
\ No newline at end of file
+}
let i = ~mut 0;
*i = 1;
assert *i == 1;
-}
\ No newline at end of file
+}
x: int
}
-impl Bar : Foo {
+impl Foo for Bar {
fn f(&self) -> int {
self.x
}
i: @mut int,
}
-impl r : Drop {
+impl Drop for r {
fn finalize(&self) {
*(self.i) = *(self.i) + 1;
}
}
assert expected == actual;
-}
\ No newline at end of file
+}
c.send(~100);
let v = p.recv();
assert v == ~100;
-}
\ No newline at end of file
+}
i <-> j;
assert i == ~200;
assert j == ~100;
-}
\ No newline at end of file
+}
{
let y = ~1;
move y;
-}
\ No newline at end of file
+}
c: SharedChan<bool>,
}
-impl complainer : Drop {
+impl Drop for complainer {
fn finalize(&self) {
error!("About to send!");
self.c.send(true);
c: @int,
}
-impl complainer : Drop {
+impl Drop for complainer {
fn finalize(&self) {}
}
// Issue #1761
-impl int: foo { fn foo() -> int { 10 } }
+impl foo for int { fn foo() -> int { 10 } }
trait foo { fn foo() -> int; }
-pub fn main() {}
\ No newline at end of file
+pub fn main() {}
x: @mut int,
}
-impl foo : Drop {
+impl Drop for foo {
fn finalize(&self) {
*self.x += 1;
}