]> git.lizzy.rs Git - rust.git/commitdiff
De-implicit-self libcore
authorBen Striegel <ben.striegel@gmail.com>
Tue, 5 Mar 2013 03:36:15 +0000 (22:36 -0500)
committerBen Striegel <ben.striegel@gmail.com>
Tue, 5 Mar 2013 03:36:15 +0000 (22:36 -0500)
19 files changed:
src/libcore/cell.rs
src/libcore/comm.rs
src/libcore/condition.rs
src/libcore/dlist.rs
src/libcore/dvec.rs
src/libcore/hash.rs
src/libcore/mutable.rs
src/libcore/path.rs
src/libcore/pipes.rs
src/libcore/ptr.rs
src/libcore/rand.rs
src/libcore/reflect.rs
src/libcore/repr.rs
src/libcore/str.rs
src/libcore/task/mod.rs
src/libcore/tuple.rs
src/libcore/unstable/extfmt.rs
src/libstd/comm.rs
src/libstd/flatpipes.rs

index 6c35c62c3a7050aeba43782de025ed423065dfc4..a85ab1a29b782b539d7b95375c099499cc033f76 100644 (file)
@@ -30,7 +30,7 @@ pub fn Cell<T>(value: T) -> Cell<T> {
 
 pub impl<T> Cell<T> {
     /// Yields the value, failing if the cell is empty.
-    fn take() -> T {
+    fn take(&self) -> T {
         if self.is_empty() {
             fail!(~"attempt to take an empty cell");
         }
@@ -41,7 +41,7 @@ fn take() -> T {
     }
 
     /// Returns the value, failing if the cell is full.
-    fn put_back(value: T) {
+    fn put_back(&self, value: T) {
         if !self.is_empty() {
             fail!(~"attempt to put a value back into a full cell");
         }
@@ -49,12 +49,12 @@ fn put_back(value: T) {
     }
 
     /// Returns true if the cell is empty and false if the cell is full.
-    pure fn is_empty() -> bool {
+    pure fn is_empty(&self) -> bool {
         self.value.is_none()
     }
 
     // Calls a closure with a reference to the value.
-    fn with_ref<R>(op: fn(v: &T) -> R) -> R {
+    fn with_ref<R>(&self, op: fn(v: &T) -> R) -> R {
         let v = self.take();
         let r = op(&v);
         self.put_back(v);
index 94272f63e6727388405413a19138e8dcc2bda0fc..4f812a5ae7693214ba7a4c11280d8d8da3009240 100644 (file)
 /// A trait for things that can send multiple messages.
 pub trait GenericChan<T> {
     /// Sends a message.
-    fn send(x: T);
+    fn send(&self, x: T);
 }
 
 /// Things that can send multiple messages and can detect when the receiver
 /// is closed
 pub trait GenericSmartChan<T> {
     /// Sends a message, or report if the receiver has closed the connection.
-    fn try_send(x: T) -> bool;
+    fn try_send(&self, x: T) -> bool;
 }
 
 /// A trait for things that can receive multiple messages.
 pub trait GenericPort<T> {
     /// Receives a message, or fails if the connection closes.
-    fn recv() -> T;
+    fn recv(&self) -> T;
 
     /** Receives a message, or returns `none` if
     the connection is closed or closes.
     */
-    fn try_recv() -> Option<T>;
+    fn try_recv(&self) -> Option<T>;
 }
 
 /// Ports that can `peek`
 pub trait Peekable<T> {
     /// Returns true if a message is available
-    pure fn peek() -> bool;
+    pure fn peek(&self) -> bool;
 }
 
 /// Returns the index of an endpoint that is ready to receive.
@@ -105,7 +105,7 @@ pub fn stream<T:Owned>() -> (Port<T>, Chan<T>) {
 }
 
 impl<T: Owned> GenericChan<T> for Chan<T> {
-    fn send(x: T) {
+    fn send(&self, x: T) {
         let mut endp = None;
         endp <-> self.endp;
         self.endp = Some(
@@ -115,7 +115,7 @@ fn send(x: T) {
 
 impl<T: Owned> GenericSmartChan<T> for Chan<T> {
 
-    fn try_send(x: T) -> bool {
+    fn try_send(&self, x: T) -> bool {
         let mut endp = None;
         endp <-> self.endp;
         match streamp::client::try_data(unwrap(endp), x) {
@@ -129,7 +129,7 @@ fn try_send(x: T) -> bool {
 }
 
 impl<T: Owned> GenericPort<T> for Port<T> {
-    fn recv() -> T {
+    fn recv(&self) -> T {
         let mut endp = None;
         endp <-> self.endp;
         let streamp::data(x, endp) = recv(unwrap(endp));
@@ -137,7 +137,7 @@ fn recv() -> T {
         x
     }
 
-    fn try_recv() -> Option<T> {
+    fn try_recv(&self) -> Option<T> {
         let mut endp = None;
         endp <-> self.endp;
         match try_recv(unwrap(endp)) {
@@ -151,7 +151,7 @@ fn try_recv() -> Option<T> {
 }
 
 impl<T: Owned> Peekable<T> for Port<T> {
-    pure fn peek() -> bool {
+    pure fn peek(&self) -> bool {
         unsafe {
             let mut endp = None;
             endp <-> self.endp;
@@ -166,7 +166,7 @@ impl<T: Owned> Peekable<T> for Port<T> {
 }
 
 impl<T: Owned> Selectable for Port<T> {
-    pure fn header() -> *PacketHeader {
+    pure fn header(&self) -> *PacketHeader {
         unsafe {
             match self.endp {
               Some(ref endp) => endp.header(),
@@ -189,11 +189,11 @@ pub fn PortSet<T: Owned>() -> PortSet<T>{
 
 pub impl<T: Owned> PortSet<T> {
 
-    fn add(port: Port<T>) {
+    fn add(&self, port: Port<T>) {
         self.ports.push(port)
     }
 
-    fn chan() -> Chan<T> {
+    fn chan(&self) -> Chan<T> {
         let (po, ch) = stream();
         self.add(po);
         ch
@@ -202,7 +202,7 @@ fn chan() -> Chan<T> {
 
 impl<T: Owned> GenericPort<T> for PortSet<T> {
 
-    fn try_recv() -> Option<T> {
+    fn try_recv(&self) -> Option<T> {
         let mut result = None;
         // we have to swap the ports array so we aren't borrowing
         // aliasable mutable memory.
@@ -224,14 +224,14 @@ fn try_recv() -> Option<T> {
         result
     }
 
-    fn recv() -> T {
+    fn recv(&self) -> T {
         self.try_recv().expect("port_set: endpoints closed")
     }
 
 }
 
 impl<T: Owned> Peekable<T> for PortSet<T> {
-    pure fn peek() -> bool {
+    pure fn peek(&self) -> bool {
         // It'd be nice to use self.port.each, but that version isn't
         // pure.
         for vec::each(self.ports) |p| {
@@ -245,7 +245,7 @@ impl<T: Owned> Peekable<T> for PortSet<T> {
 pub type SharedChan<T> = unstable::Exclusive<Chan<T>>;
 
 impl<T: Owned> GenericChan<T> for SharedChan<T> {
-    fn send(x: T) {
+    fn send(&self, x: T) {
         let mut xx = Some(x);
         do self.with_imm |chan| {
             let mut x = None;
@@ -256,7 +256,7 @@ fn send(x: T) {
 }
 
 impl<T: Owned> GenericSmartChan<T> for SharedChan<T> {
-    fn try_send(x: T) -> bool {
+    fn try_send(&self, x: T) -> bool {
         let mut xx = Some(x);
         do self.with_imm |chan| {
             let mut x = None;
@@ -274,9 +274,9 @@ pub fn SharedChan<T:Owned>(c: Chan<T>) -> SharedChan<T> {
 /// Receive a message from one of two endpoints.
 pub trait Select2<T: Owned, U: Owned> {
     /// Receive a message or return `None` if a connection closes.
-    fn try_select() -> Either<Option<T>, Option<U>>;
+    fn try_select(&self) -> Either<Option<T>, Option<U>>;
     /// Receive a message or fail if a connection closes.
-    fn select() -> Either<T, U>;
+    fn select(&self) -> Either<T, U>;
 }
 
 impl<T: Owned, U: Owned,
@@ -284,8 +284,8 @@ impl<T: Owned, U: Owned,
      Right: Selectable + GenericPort<U>>
     Select2<T, U> for (Left, Right) {
 
-    fn select() -> Either<T, U> {
-        match self {
+    fn select(&self) -> Either<T, U> {
+        match *self {
           (ref lp, ref rp) => match select2i(lp, rp) {
             Left(()) => Left (lp.recv()),
             Right(()) => Right(rp.recv())
@@ -293,8 +293,8 @@ fn select() -> Either<T, U> {
         }
     }
 
-    fn try_select() -> Either<Option<T>, Option<U>> {
-        match self {
+    fn try_select(&self) -> Either<Option<T>, Option<U>> {
+        match *self {
           (ref lp, ref rp) => match select2i(lp, rp) {
             Left(()) => Left (lp.try_recv()),
             Right(()) => Right(rp.try_recv())
index 00048beae5acb831b01f959c49fc0682d370a73f..87752cff1bfa2239aac2e6ec331ada0d785df563 100644 (file)
@@ -35,12 +35,12 @@ fn trap(&self, h: &self/fn(T) -> U) -> Trap/&self<T, U> {
         }
     }
 
-    fn raise(t: T) -> U {
+    fn raise(&self, t: T) -> U {
         let msg = fmt!("Unhandled condition: %s: %?", self.name, t);
         self.raise_default(t, || fail!(copy msg))
     }
 
-    fn raise_default(t: T, default: &fn() -> U) -> U {
+    fn raise_default(&self, t: T, default: &fn() -> U) -> U {
         unsafe {
             match local_data_pop(self.key) {
                 None => {
index f1f4e55866101b05284475fc77cc6d2505690d25..34a3c3e60af23db0849bc6cf8231a35a0100c878 100644 (file)
@@ -148,7 +148,7 @@ pub fn concat<T>(lists: @mut DList<@mut DList<T>>) -> @mut DList<T> {
             fail!(~"That node isn't on this dlist.")
         }
     }
-    fn make_mine(nobe: @mut DListNode<T>) {
+    fn make_mine(&self, nobe: @mut DListNode<T>) {
         if nobe.prev.is_some() || nobe.next.is_some() || nobe.linked {
             fail!(~"Cannot insert node that's already on a dlist!")
         }
index 7197de36404ede7c1cec124b8b5c1d58700921fe..2f87d05d8fe2df5d43e687abfa8cd4246ac396af 100644 (file)
@@ -83,7 +83,7 @@ pub struct DVec<A> {
 
 priv impl<A> DVec<A> {
     #[inline(always)]
-    pure fn check_not_borrowed() {
+    pure fn check_not_borrowed(&self) {
         unsafe {
             let data: *() = cast::reinterpret_cast(&self.data);
             if data.is_null() {
@@ -93,7 +93,7 @@ pub struct DVec<A> {
     }
 
     #[inline(always)]
-    fn give_back(data: ~[A]) {
+    fn give_back(&self, data: ~[A]) {
         unsafe {
             self.data = data;
         }
@@ -120,7 +120,7 @@ fn check_out<B>(f: &fn(v: ~[A]) -> B) -> B {
     }
 
     /// Reserves space for N elements
-    fn reserve(count: uint) {
+    fn reserve(&self, count: uint) {
         vec::reserve(&mut self.data, count)
     }
 
@@ -130,26 +130,26 @@ fn reserve(count: uint) {
      * and return a new vector to replace it with.
      */
     #[inline(always)]
-    fn swap(f: &fn(v: ~[A]) -> ~[A]) {
+    fn swap(&self, f: &fn(v: ~[A]) -> ~[A]) {
         self.check_out(|v| self.give_back(f(v)))
     }
 
     /// Returns the number of elements currently in the dvec
     #[inline(always)]
-    pure fn len() -> uint {
+    pure fn len(&self) -> uint {
         self.check_not_borrowed();
         return self.data.len();
     }
 
     /// Overwrite the current contents
     #[inline(always)]
-    fn set(w: ~[A]) {
+    fn set(&self, w: ~[A]) {
         self.check_not_borrowed();
         self.data = w;
     }
 
     /// Remove and return the last element
-    fn pop() -> A {
+    fn pop(&self) -> A {
         do self.check_out |v| {
             let mut v = v;
             let result = v.pop();
@@ -159,7 +159,7 @@ fn pop() -> A {
     }
 
     /// Insert a single item at the front of the list
-    fn unshift(t: A) {
+    fn unshift(&self, t: A) {
         unsafe {
             let mut data = cast::reinterpret_cast(&null::<()>());
             data <-> self.data;
@@ -172,13 +172,13 @@ fn unshift(t: A) {
 
     /// Append a single item to the end of the list
     #[inline(always)]
-    fn push(t: A) {
+    fn push(&self, t: A) {
         self.check_not_borrowed();
         self.data.push(t);
     }
 
     /// Remove and return the first element
-    fn shift() -> A {
+    fn shift(&self) -> A {
         do self.check_out |v| {
             let mut v = v;
             let result = v.shift();
@@ -188,7 +188,7 @@ fn shift() -> A {
     }
 
     /// Reverse the elements in the list, in place
-    fn reverse() {
+    fn reverse(&self) {
         do self.check_out |v| {
             let mut v = v;
             vec::reverse(v);
@@ -197,7 +197,7 @@ fn reverse() {
     }
 
     /// Gives access to the vector as a slice with immutable contents
-    fn borrow<R>(op: fn(x: &[A]) -> R) -> R {
+    fn borrow<R>(&self, op: fn(x: &[A]) -> R) -> R {
         do self.check_out |v| {
             let result = op(v);
             self.give_back(v);
@@ -206,7 +206,7 @@ fn borrow<R>(op: fn(x: &[A]) -> R) -> R {
     }
 
     /// Gives access to the vector as a slice with mutable contents
-    fn borrow_mut<R>(op: &fn(x: &mut [A]) -> R) -> R {
+    fn borrow_mut<R>(&self, op: &fn(x: &mut [A]) -> R) -> R {
         do self.check_out |v| {
             let mut v = v;
             let result = op(v);
@@ -222,12 +222,12 @@ pub impl<A:Copy> DVec<A> {
      *
      * Equivalent to `append_iter()` but potentially more efficient.
      */
-    fn push_all(ts: &[const A]) {
+    fn push_all(&self, ts: &[const A]) {
         self.push_slice(ts, 0u, vec::len(ts));
     }
 
     /// Appends elements from `from_idx` to `to_idx` (exclusive)
-    fn push_slice(ts: &[const A], from_idx: uint, to_idx: uint) {
+    fn push_slice(&self, ts: &[const A], from_idx: uint, to_idx: uint) {
         do self.swap |v| {
             let mut v = v;
             let new_len = vec::len(v) + to_idx - from_idx;
@@ -271,7 +271,7 @@ fn append_iter<A, I:iter::base_iter<A>>(ts: I) {
      *
      * See `unwrap()` if you do not wish to copy the contents.
      */
-    pure fn get() -> ~[A] {
+    pure fn get(&self) -> ~[A] {
         unsafe {
             do self.check_out |v| {
                 let w = copy v;
@@ -283,13 +283,13 @@ fn append_iter<A, I:iter::base_iter<A>>(ts: I) {
 
     /// Copy out an individual element
     #[inline(always)]
-    pure fn get_elt(idx: uint) -> A {
+    pure fn get_elt(&self, idx: uint) -> A {
         self.check_not_borrowed();
         return self.data[idx];
     }
 
     /// Overwrites the contents of the element at `idx` with `a`
-    fn set_elt(idx: uint, a: A) {
+    fn set_elt(&self, idx: uint, a: A) {
         self.check_not_borrowed();
         self.data[idx] = a;
     }
@@ -299,7 +299,7 @@ fn set_elt(idx: uint, a: A) {
      * growing the vector if necessary.  New elements will be initialized
      * with `initval`
      */
-    fn grow_set_elt(idx: uint, initval: &A, val: A) {
+    fn grow_set_elt(&self, idx: uint, initval: &A, val: A) {
         do self.swap |v| {
             let mut v = v;
             v.grow_set(idx, initval, val);
@@ -309,7 +309,7 @@ fn grow_set_elt(idx: uint, initval: &A, val: A) {
 
     /// Returns the last element, failing if the vector is empty
     #[inline(always)]
-    pure fn last() -> A {
+    pure fn last(&self) -> A {
         self.check_not_borrowed();
 
         let length = self.len();
@@ -322,7 +322,7 @@ fn grow_set_elt(idx: uint, initval: &A, val: A) {
 
     /// Iterates over the elements in reverse order
     #[inline(always)]
-    fn rev_each(f: fn(v: &A) -> bool) {
+    fn rev_each(&self, f: fn(v: &A) -> bool) {
         do self.swap |v| {
             // FIXME(#2263)---we should be able to write
             // `vec::rev_each(v, f);` but we cannot write now
@@ -335,7 +335,7 @@ fn rev_each(f: fn(v: &A) -> bool) {
 
     /// Iterates over the elements and indices in reverse order
     #[inline(always)]
-    fn rev_eachi(f: fn(uint, v: &A) -> bool) {
+    fn rev_eachi(&self, f: fn(uint, v: &A) -> bool) {
         do self.swap |v| {
             // FIXME(#2263)---we should be able to write
             // `vec::rev_eachi(v, f);` but we cannot write now
index 4a1a1952907c6f65a800041478ca7e63127601fc..39d86380bdc991fb97111900419579fbe6efa49e 100644 (file)
@@ -51,32 +51,32 @@ pub trait Hash {
      * function and require most types to only implement the
      * IterBytes trait, that feeds SipHash.
      */
-    pure fn hash_keyed(k0: u64, k1: u64) -> u64;
+    pure fn hash_keyed(&self, k0: u64, k1: u64) -> u64;
 }
 
 // When we have default methods, won't need this.
 pub trait HashUtil {
-    pure fn hash() -> u64;
+    pure fn hash(&self) -> u64;
 }
 
 impl<A:Hash> HashUtil for A {
     #[inline(always)]
-    pure fn hash() -> u64 { self.hash_keyed(0,0) }
+    pure fn hash(&self) -> u64 { self.hash_keyed(0,0) }
 }
 
 /// Streaming hash-functions should implement this.
 pub trait Streaming {
-    fn input((&[const u8]));
+    fn input(&self, (&[const u8]));
     // These can be refactored some when we have default methods.
-    fn result_bytes() -> ~[u8];
+    fn result_bytes(&self) -> ~[u8];
     fn result_str() -> ~str;
-    fn result_u64() -> u64;
-    fn reset();
+    fn result_u64(&self) -> u64;
+    fn reset(&self);
 }
 
 impl<A:IterBytes> Hash for A {
     #[inline(always)]
-    pure fn hash_keyed(k0: u64, k1: u64) -> u64 {
+    pure fn hash_keyed(&self, k0: u64, k1: u64) -> u64 {
         unsafe {
             let s = &State(k0, k1);
             for self.iter_bytes(true) |bytes| {
@@ -302,12 +302,12 @@ fn get_type(&self) -> io::WriterType {
 impl Streaming for &SipState {
 
     #[inline(always)]
-    fn input(buf: &[const u8]) {
+    fn input(&self, buf: &[const u8]) {
         self.write(buf);
     }
 
     #[inline(always)]
-    fn result_u64() -> u64 {
+    fn result_u64(&self) -> u64 {
         let mut v0 = self.v0;
         let mut v1 = self.v1;
         let mut v2 = self.v2;
@@ -337,7 +337,7 @@ fn result_u64() -> u64 {
         return (v0 ^ v1 ^ v2 ^ v3);
     }
 
-    fn result_bytes() -> ~[u8] {
+    fn result_bytes(&self) -> ~[u8] {
         let h = self.result_u64();
         ~[(h >> 0) as u8,
           (h >> 8) as u8,
@@ -350,6 +350,7 @@ fn result_bytes() -> ~[u8] {
         ]
     }
 
+    // IMPLICIT SELF WARNING: fix me!
     fn result_str() -> ~str {
         let r = self.result_bytes();
         let mut s = ~"";
@@ -360,7 +361,7 @@ fn result_str() -> ~str {
     }
 
     #[inline(always)]
-    fn reset() {
+    fn reset(&self) {
         self.length = 0;
         self.v0 = self.k0 ^ 0x736f6d6570736575;
         self.v1 = self.k1 ^ 0x646f72616e646f6d;
index f888fbdb40cc6421e1bf33a16db0ea4828fd5191..e4b8d204dd7edb0c50fa2b24d1396f6add4539bc 100644 (file)
@@ -44,7 +44,7 @@ pub fn unwrap<T>(m: Mut<T>) -> T {
 }
 
 pub impl<T> Data<T> {
-    fn borrow_mut<R>(op: &fn(t: &mut T) -> R) -> R {
+    fn borrow_mut<R>(&self, op: &fn(t: &mut T) -> R) -> R {
         match self.mode {
             Immutable => fail!(fmt!("%? currently immutable",
                                    self.value)),
@@ -56,11 +56,11 @@ fn borrow_mut<R>(op: &fn(t: &mut T) -> R) -> R {
         }
     }
 
-    pure fn borrow_const<R>(op: &fn(t: &const T) -> R) -> R {
+    pure fn borrow_const<R>(&self, op: &fn(t: &const T) -> R) -> R {
         op(&const self.value)
     }
 
-    fn borrow_imm<R>(op: &fn(t: &T) -> R) -> R {
+    fn borrow_imm<R>(&self, op: &fn(t: &T) -> R) -> R {
         match self.mode {
           Mutable => fail!(fmt!("%? currently mutable",
                                self.value)),
index 8d528a11598394601b753c03b7d1a66d7c52dcaa..f621b140638a4c503b3215f5258ea68b2a77518b 100644 (file)
@@ -46,28 +46,28 @@ pub struct PosixPath {
 pub trait GenericPath {
     static pure fn from_str(&str) -> Self;
 
-    pure fn dirname() -> ~str;
-    pure fn filename() -> Option<~str>;
-    pure fn filestem() -> Option<~str>;
-    pure fn filetype() -> Option<~str>;
+    pure fn dirname(&self) -> ~str;
+    pure fn filename(&self) -> Option<~str>;
+    pure fn filestem(&self) -> Option<~str>;
+    pure fn filetype(&self) -> Option<~str>;
 
-    pure fn with_dirname((&str)) -> Self;
-    pure fn with_filename((&str)) -> Self;
-    pure fn with_filestem((&str)) -> Self;
-    pure fn with_filetype((&str)) -> Self;
+    pure fn with_dirname(&self, (&str)) -> Self;
+    pure fn with_filename(&self, (&str)) -> Self;
+    pure fn with_filestem(&self, (&str)) -> Self;
+    pure fn with_filetype(&self, (&str)) -> Self;
 
-    pure fn dir_path() -> Self;
-    pure fn file_path() -> Self;
+    pure fn dir_path(&self) -> Self;
+    pure fn file_path(&self) -> Self;
 
-    pure fn push((&str)) -> Self;
-    pure fn push_rel((&Self)) -> Self;
-    pure fn push_many((&[~str])) -> Self;
-    pure fn pop() -> Self;
+    pure fn push(&self, (&str)) -> Self;
+    pure fn push_rel(&self, (&Self)) -> Self;
+    pure fn push_many(&self, (&[~str])) -> Self;
+    pure fn pop(&self) -> Self;
 
-    pure fn unsafe_join((&Self)) -> Self;
-    pure fn is_restricted() -> bool;
+    pure fn unsafe_join(&self, (&Self)) -> Self;
+    pure fn is_restricted(&self) -> bool;
 
-    pure fn normalize() -> Self;
+    pure fn normalize(&self) -> Self;
 }
 
 #[cfg(windows)]
@@ -388,7 +388,7 @@ impl GenericPath for PosixPath {
                            components: components }
     }
 
-    pure fn dirname() -> ~str {
+    pure fn dirname(&self) -> ~str {
         unsafe {
             let s = self.dir_path().to_str();
             if s.len() == 0 {
@@ -399,14 +399,14 @@ impl GenericPath for PosixPath {
         }
     }
 
-    pure fn filename() -> Option<~str> {
+    pure fn filename(&self) -> Option<~str> {
         match self.components.len() {
           0 => None,
           n => Some(copy self.components[n - 1])
         }
     }
 
-    pure fn filestem() -> Option<~str> {
+    pure fn filestem(&self) -> Option<~str> {
         match self.filename() {
           None => None,
           Some(ref f) => {
@@ -418,7 +418,7 @@ impl GenericPath for PosixPath {
         }
     }
 
-    pure fn filetype() -> Option<~str> {
+    pure fn filetype(&self) -> Option<~str> {
         match self.filename() {
           None => None,
           Some(ref f) => {
@@ -430,7 +430,7 @@ impl GenericPath for PosixPath {
         }
     }
 
-    pure fn with_dirname(d: &str) -> PosixPath {
+    pure fn with_dirname(&self, d: &str) -> PosixPath {
         let dpath = PosixPath(d);
         match self.filename() {
           Some(ref f) => dpath.push(*f),
@@ -438,24 +438,24 @@ impl GenericPath for PosixPath {
         }
     }
 
-    pure fn with_filename(f: &str) -> PosixPath {
+    pure fn with_filename(&self, f: &str) -> PosixPath {
         unsafe {
             assert ! str::any(f, |c| windows::is_sep(c as u8));
             self.dir_path().push(f)
         }
     }
 
-    pure fn with_filestem(s: &str) -> PosixPath {
+    pure fn with_filestem(&self, s: &str) -> PosixPath {
         match self.filetype() {
           None => self.with_filename(s),
           Some(ref t) => self.with_filename(str::from_slice(s) + *t)
         }
     }
 
-    pure fn with_filetype(t: &str) -> PosixPath {
+    pure fn with_filetype(&self, t: &str) -> PosixPath {
         if t.len() == 0 {
             match self.filestem() {
-              None => copy self,
+              None => copy *self,
               Some(ref s) => self.with_filename(*s)
             }
         } else {
@@ -467,15 +467,15 @@ impl GenericPath for PosixPath {
         }
     }
 
-    pure fn dir_path() -> PosixPath {
+    pure fn dir_path(&self) -> PosixPath {
         if self.components.len() != 0 {
             self.pop()
         } else {
-            copy self
+            copy *self
         }
     }
 
-    pure fn file_path() -> PosixPath {
+    pure fn file_path(&self) -> PosixPath {
         let cs = match self.filename() {
           None => ~[],
           Some(ref f) => ~[copy *f]
@@ -484,12 +484,12 @@ impl GenericPath for PosixPath {
                            components: cs }
     }
 
-    pure fn push_rel(other: &PosixPath) -> PosixPath {
+    pure fn push_rel(&self, other: &PosixPath) -> PosixPath {
         assert !other.is_absolute;
         self.push_many(other.components)
     }
 
-    pure fn unsafe_join(other: &PosixPath) -> PosixPath {
+    pure fn unsafe_join(&self, other: &PosixPath) -> PosixPath {
         if other.is_absolute {
             PosixPath { is_absolute: true,
                         components: copy other.components }
@@ -498,11 +498,11 @@ impl GenericPath for PosixPath {
         }
     }
 
-    pure fn is_restricted() -> bool {
+    pure fn is_restricted(&self) -> bool {
         false
     }
 
-    pure fn push_many(cs: &[~str]) -> PosixPath {
+    pure fn push_many(&self, cs: &[~str]) -> PosixPath {
         let mut v = copy self.components;
         for cs.each |e| {
             let mut ss = str::split_nonempty(
@@ -514,14 +514,14 @@ impl GenericPath for PosixPath {
                     components: v }
     }
 
-    pure fn push(s: &str) -> PosixPath {
+    pure fn push(&self, s: &str) -> PosixPath {
         let mut v = copy self.components;
         let mut ss = str::split_nonempty(s, |c| windows::is_sep(c as u8));
         unsafe { v.push_all_move(ss); }
-        PosixPath { components: v, ..copy self }
+        PosixPath { components: v, ..copy *self }
     }
 
-    pure fn pop() -> PosixPath {
+    pure fn pop(&self) -> PosixPath {
         let mut cs = copy self.components;
         if cs.len() != 0 {
             unsafe { cs.pop(); }
@@ -533,7 +533,7 @@ impl GenericPath for PosixPath {
                           //..self }
     }
 
-    pure fn normalize() -> PosixPath {
+    pure fn normalize(&self) -> PosixPath {
         return PosixPath {
             is_absolute: self.is_absolute,
             components: normalize(self.components)
@@ -600,7 +600,7 @@ impl GenericPath for WindowsPath {
                              components: components }
     }
 
-    pure fn dirname() -> ~str {
+    pure fn dirname(&self) -> ~str {
         unsafe {
             let s = self.dir_path().to_str();
             if s.len() == 0 {
@@ -611,14 +611,14 @@ impl GenericPath for WindowsPath {
         }
     }
 
-    pure fn filename() -> Option<~str> {
+    pure fn filename(&self) -> Option<~str> {
         match self.components.len() {
           0 => None,
           n => Some(copy self.components[n - 1])
         }
     }
 
-    pure fn filestem() -> Option<~str> {
+    pure fn filestem(&self) -> Option<~str> {
         match self.filename() {
           None => None,
           Some(ref f) => {
@@ -630,7 +630,7 @@ impl GenericPath for WindowsPath {
         }
     }
 
-    pure fn filetype() -> Option<~str> {
+    pure fn filetype(&self) -> Option<~str> {
         match self.filename() {
           None => None,
           Some(ref f) => {
@@ -642,7 +642,7 @@ impl GenericPath for WindowsPath {
         }
     }
 
-    pure fn with_dirname(d: &str) -> WindowsPath {
+    pure fn with_dirname(&self, d: &str) -> WindowsPath {
         let dpath = WindowsPath(d);
         match self.filename() {
           Some(ref f) => dpath.push(*f),
@@ -650,22 +650,22 @@ impl GenericPath for WindowsPath {
         }
     }
 
-    pure fn with_filename(f: &str) -> WindowsPath {
+    pure fn with_filename(&self, f: &str) -> WindowsPath {
         assert ! str::any(f, |c| windows::is_sep(c as u8));
         self.dir_path().push(f)
     }
 
-    pure fn with_filestem(s: &str) -> WindowsPath {
+    pure fn with_filestem(&self, s: &str) -> WindowsPath {
         match self.filetype() {
           None => self.with_filename(s),
           Some(ref t) => self.with_filename(str::from_slice(s) + *t)
         }
     }
 
-    pure fn with_filetype(t: &str) -> WindowsPath {
+    pure fn with_filetype(&self, t: &str) -> WindowsPath {
         if t.len() == 0 {
             match self.filestem() {
-              None => copy self,
+              None => copy *self,
               Some(ref s) => self.with_filename(*s)
             }
         } else {
@@ -678,15 +678,15 @@ impl GenericPath for WindowsPath {
         }
     }
 
-    pure fn dir_path() -> WindowsPath {
+    pure fn dir_path(&self) -> WindowsPath {
         if self.components.len() != 0 {
             self.pop()
         } else {
-            copy self
+            copy *self
         }
     }
 
-    pure fn file_path() -> WindowsPath {
+    pure fn file_path(&self) -> WindowsPath {
         let cs = match self.filename() {
           None => ~[],
           Some(ref f) => ~[copy *f]
@@ -697,12 +697,12 @@ impl GenericPath for WindowsPath {
                              components: cs }
     }
 
-    pure fn push_rel(other: &WindowsPath) -> WindowsPath {
+    pure fn push_rel(&self, other: &WindowsPath) -> WindowsPath {
         assert !other.is_absolute;
         self.push_many(other.components)
     }
 
-    pure fn unsafe_join(other: &WindowsPath) -> WindowsPath {
+    pure fn unsafe_join(&self, other: &WindowsPath) -> WindowsPath {
         /* rhs not absolute is simple push */
         if !other.is_absolute {
             return self.push_many(other.components);
@@ -744,7 +744,7 @@ impl GenericPath for WindowsPath {
         }
     }
 
-    pure fn is_restricted() -> bool {
+    pure fn is_restricted(&self) -> bool {
         match self.filestem() {
             Some(stem) => {
                 match stem.to_lower() {
@@ -757,7 +757,7 @@ impl GenericPath for WindowsPath {
         }
     }
 
-    pure fn push_many(cs: &[~str]) -> WindowsPath {
+    pure fn push_many(&self, cs: &[~str]) -> WindowsPath {
         let mut v = copy self.components;
         for cs.each |e| {
             let mut ss = str::split_nonempty(
@@ -774,14 +774,14 @@ impl GenericPath for WindowsPath {
         }
     }
 
-    pure fn push(s: &str) -> WindowsPath {
+    pure fn push(&self, s: &str) -> WindowsPath {
         let mut v = copy self.components;
         let mut ss = str::split_nonempty(s, |c| windows::is_sep(c as u8));
         unsafe { v.push_all_move(ss); }
-        return WindowsPath { components: v, ..copy self }
+        return WindowsPath { components: v, ..copy *self }
     }
 
-    pure fn pop() -> WindowsPath {
+    pure fn pop(&self) -> WindowsPath {
         let mut cs = copy self.components;
         if cs.len() != 0 {
             unsafe { cs.pop(); }
@@ -794,7 +794,7 @@ impl GenericPath for WindowsPath {
         }
     }
 
-    pure fn normalize() -> WindowsPath {
+    pure fn normalize(&self) -> WindowsPath {
         return WindowsPath {
             host: copy self.host,
             device: match self.device {
index e4fc9528f23fc2e31077af2d901493831d8ec7bf..1bbd5b06776aab0eaa00dd556f7d74c1e8bf174f 100644 (file)
@@ -160,14 +160,14 @@ pub fn PacketHeader() -> PacketHeader {
 
 pub impl PacketHeader {
     // Returns the old state.
-    unsafe fn mark_blocked(this: *rust_task) -> State {
+    unsafe fn mark_blocked(&self, this: *rust_task) -> State {
         rustrt::rust_task_ref(this);
         let old_task = swap_task(&mut self.blocked_task, this);
         assert old_task.is_null();
         swap_state_acq(&mut self.state, Blocked)
     }
 
-    unsafe fn unblock() {
+    unsafe fn unblock(&self) {
         let old_task = swap_task(&mut self.blocked_task, ptr::null());
         if !old_task.is_null() {
             unsafe {
@@ -184,12 +184,12 @@ unsafe fn unblock() {
     // unsafe because this can do weird things to the space/time
     // continuum. It ends making multiple unique pointers to the same
     // thing. You'll proobably want to forget them when you're done.
-    unsafe fn buf_header() -> ~BufferHeader {
+    unsafe fn buf_header(&self) -> ~BufferHeader {
         assert self.buffer.is_not_null();
         reinterpret_cast(&self.buffer)
     }
 
-    fn set_buffer<T:Owned>(b: ~Buffer<T>) {
+    fn set_buffer<T:Owned>(&self, b: ~Buffer<T>) {
         unsafe {
             self.buffer = reinterpret_cast(&b);
         }
@@ -204,11 +204,11 @@ pub struct Packet<T> {
 
 #[doc(hidden)]
 pub trait HasBuffer {
-    fn set_buffer(b: *libc::c_void);
+    fn set_buffer(&self, b: *libc::c_void);
 }
 
 impl<T:Owned> HasBuffer for Packet<T> {
-    fn set_buffer(b: *libc::c_void) {
+    fn set_buffer(&self, b: *libc::c_void) {
         self.header.buffer = b;
     }
 }
@@ -717,11 +717,11 @@ pub fn select2<A:Owned,Ab:Owned,B:Owned,Bb:Owned>(
 
 #[doc(hidden)]
 pub trait Selectable {
-    pure fn header() -> *PacketHeader;
+    pure fn header(&self) -> *PacketHeader;
 }
 
 impl Selectable for *PacketHeader {
-    pure fn header() -> *PacketHeader { self }
+    pure fn header(&self) -> *PacketHeader { *self }
 }
 
 /// Returns the index of an endpoint that is ready to receive.
@@ -799,13 +799,13 @@ pub fn SendPacketBuffered<T,Tbuffer>(p: *Packet<T>)
 }
 
 pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
-    fn unwrap() -> *Packet<T> {
+    fn unwrap(&self) -> *Packet<T> {
         let mut p = None;
         p <-> self.p;
         option::unwrap(p)
     }
 
-    pure fn header() -> *PacketHeader {
+    pure fn header(&self) -> *PacketHeader {
         match self.p {
           Some(packet) => unsafe {
             let packet = &*packet;
@@ -817,7 +817,7 @@ fn unwrap() -> *Packet<T> {
         }
     }
 
-    fn reuse_buffer() -> BufferResource<Tbuffer> {
+    fn reuse_buffer(&self) -> BufferResource<Tbuffer> {
         //error!("send reuse_buffer");
         let mut tmp = None;
         tmp <-> self.buffer;
@@ -856,13 +856,13 @@ fn finalize(&self) {
 }
 
 pub impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
-    fn unwrap() -> *Packet<T> {
+    fn unwrap(&self) -> *Packet<T> {
         let mut p = None;
         p <-> self.p;
         option::unwrap(p)
     }
 
-    fn reuse_buffer() -> BufferResource<Tbuffer> {
+    fn reuse_buffer(&self) -> BufferResource<Tbuffer> {
         //error!("recv reuse_buffer");
         let mut tmp = None;
         tmp <-> self.buffer;
@@ -871,7 +871,7 @@ fn reuse_buffer() -> BufferResource<Tbuffer> {
 }
 
 impl<T:Owned,Tbuffer:Owned> Selectable for RecvPacketBuffered<T, Tbuffer> {
-    pure fn header() -> *PacketHeader {
+    pure fn header(&self) -> *PacketHeader {
         match self.p {
           Some(packet) => unsafe {
             let packet = &*packet;
index ecbce18e6daaef908a0e9c36c9d13c50b899d94c..1352615767e4fb2d6eff6c772f0821e1f710db3f 100644 (file)
@@ -175,39 +175,39 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: int, count: uint) {
 }
 
 pub trait Ptr<T> {
-    pure fn is_null() -> bool;
-    pure fn is_not_null() -> bool;
-    pure fn offset(count: uint) -> Self;
+    pure fn is_null(&self) -> bool;
+    pure fn is_not_null(&self) -> bool;
+    pure fn offset(&self, count: uint) -> Self;
 }
 
 /// Extension methods for immutable pointers
 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) }
+    pure fn is_null(&self) -> bool { is_null(*self) }
 
     /// Returns true if the pointer is not equal to the null pointer.
     #[inline(always)]
-    pure fn is_not_null() -> bool { is_not_null(self) }
+    pure fn is_not_null(&self) -> bool { is_not_null(*self) }
 
     /// Calculates the offset from a pointer.
     #[inline(always)]
-    pure fn offset(count: uint) -> *T { offset(self, count) }
+    pure fn offset(&self, count: uint) -> *T { offset(*self, count) }
 }
 
 /// Extension methods for mutable pointers
 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) }
+    pure fn is_null(&self) -> bool { is_null(*self) }
 
     /// Returns true if the pointer is not equal to the null pointer.
     #[inline(always)]
-    pure fn is_not_null() -> bool { is_not_null(self) }
+    pure fn is_not_null(&self) -> bool { is_not_null(*self) }
 
     /// Calculates the offset from a mutable pointer.
     #[inline(always)]
-    pure fn offset(count: uint) -> *mut T { mut_offset(self, count) }
+    pure fn offset(&self, count: uint) -> *mut T { mut_offset(*self, count) }
 }
 
 // Equality for pointers
index d9c2b91fb972207a813406ba3d8a88009b47dfac..377bf5bf4e7cd6da775db6bec15cbb77139a6824 100644 (file)
@@ -131,7 +131,7 @@ enum rust_rng {}
 /// A random number generator
 pub trait Rng {
     /// Return the next random integer
-    fn next() -> u32;
+    fn next(&self) -> u32;
 }
 
 /// A value with a particular weight compared to other values
@@ -143,12 +143,12 @@ pub struct Weighted<T> {
 /// Extension methods for random number generators
 pub impl Rng {
     /// Return a random value for a Rand type
-    fn gen<T:Rand>() -> T {
-        Rand::rand(self)
+    fn gen<T:Rand>(&self) -> T {
+        Rand::rand(*self)
     }
 
     /// Return a random int
-    fn gen_int() -> int {
+    fn gen_int(&self) -> int {
         self.gen_i64() as int
     }
 
@@ -156,33 +156,33 @@ fn gen_int() -> int {
      * Return an int randomly chosen from the range [start, end),
      * failing if start >= end
      */
-    fn gen_int_range(start: int, end: int) -> int {
+    fn gen_int_range(&self, start: int, end: int) -> int {
         assert start < end;
         start + int::abs(self.gen_int() % (end - start))
     }
 
     /// Return a random i8
-    fn gen_i8() -> i8 {
+    fn gen_i8(&self) -> i8 {
         self.next() as i8
     }
 
     /// Return a random i16
-    fn gen_i16() -> i16 {
+    fn gen_i16(&self) -> i16 {
         self.next() as i16
     }
 
     /// Return a random i32
-    fn gen_i32() -> i32 {
+    fn gen_i32(&self) -> i32 {
         self.next() as i32
     }
 
     /// Return a random i64
-    fn gen_i64() -> i64 {
+    fn gen_i64(&self) -> i64 {
         (self.next() as i64 << 32) | self.next() as i64
     }
 
     /// Return a random uint
-    fn gen_uint() -> uint {
+    fn gen_uint(&self) -> uint {
         self.gen_u64() as uint
     }
 
@@ -190,43 +190,43 @@ fn gen_uint() -> uint {
      * Return a uint randomly chosen from the range [start, end),
      * failing if start >= end
      */
-    fn gen_uint_range(start: uint, end: uint) -> uint {
+    fn gen_uint_range(&self, start: uint, end: uint) -> uint {
         assert start < end;
         start + (self.gen_uint() % (end - start))
     }
 
     /// Return a random u8
-    fn gen_u8() -> u8 {
+    fn gen_u8(&self) -> u8 {
         self.next() as u8
     }
 
     /// Return a random u16
-    fn gen_u16() -> u16 {
+    fn gen_u16(&self) -> u16 {
         self.next() as u16
     }
 
     /// Return a random u32
-    fn gen_u32() -> u32 {
+    fn gen_u32(&self) -> u32 {
         self.next()
     }
 
     /// Return a random u64
-    fn gen_u64() -> u64 {
+    fn gen_u64(&self) -> u64 {
         (self.next() as u64 << 32) | self.next() as u64
     }
 
     /// Return a random float in the interval [0,1]
-    fn gen_float() -> float {
+    fn gen_float(&self) -> float {
         self.gen_f64() as float
     }
 
     /// Return a random f32 in the interval [0,1]
-    fn gen_f32() -> f32 {
+    fn gen_f32(&self) -> f32 {
         self.gen_f64() as f32
     }
 
     /// Return a random f64 in the interval [0,1]
-    fn gen_f64() -> f64 {
+    fn gen_f64(&self) -> f64 {
         let u1 = self.next() as f64;
         let u2 = self.next() as f64;
         let u3 = self.next() as f64;
@@ -235,25 +235,25 @@ fn gen_f64() -> f64 {
     }
 
     /// Return a random char
-    fn gen_char() -> char {
+    fn gen_char(&self) -> char {
         self.next() as char
     }
 
     /**
      * Return a char randomly chosen from chars, failing if chars is empty
      */
-    fn gen_char_from(chars: &str) -> char {
+    fn gen_char_from(&self, chars: &str) -> char {
         assert !chars.is_empty();
         self.choose(str::chars(chars))
     }
 
     /// Return a random bool
-    fn gen_bool() -> bool {
+    fn gen_bool(&self) -> bool {
         self.next() & 1u32 == 1u32
     }
 
     /// Return a bool with a 1 in n chance of true
-    fn gen_weighted_bool(n: uint) -> bool {
+    fn gen_weighted_bool(&self, n: uint) -> bool {
         if n == 0u {
             true
         } else {
@@ -264,7 +264,7 @@ fn gen_weighted_bool(n: uint) -> bool {
     /**
      * Return a random string of the specified length composed of A-Z,a-z,0-9
      */
-    fn gen_str(len: uint) -> ~str {
+    fn gen_str(&self, len: uint) -> ~str {
         let charset = ~"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
                        abcdefghijklmnopqrstuvwxyz\
                        0123456789";
@@ -278,19 +278,19 @@ fn gen_str(len: uint) -> ~str {
     }
 
     /// Return a random byte string of the specified length
-    fn gen_bytes(len: uint) -> ~[u8] {
+    fn gen_bytes(&self, len: uint) -> ~[u8] {
         do vec::from_fn(len) |_i| {
             self.gen_u8()
         }
     }
 
     /// Choose an item randomly, failing if values is empty
-    fn choose<T:Copy>(values: &[T]) -> T {
+    fn choose<T:Copy>(&self, values: &[T]) -> T {
         self.choose_option(values).get()
     }
 
     /// Choose Some(item) randomly, returning None if values is empty
-    fn choose_option<T:Copy>(values: &[T]) -> Option<T> {
+    fn choose_option<T:Copy>(&self, values: &[T]) -> Option<T> {
         if values.is_empty() {
             None
         } else {
@@ -302,7 +302,7 @@ fn choose_option<T:Copy>(values: &[T]) -> Option<T> {
      * Choose an item respecting the relative weights, failing if the sum of
      * the weights is 0
      */
-    fn choose_weighted<T:Copy>(v : &[Weighted<T>]) -> T {
+    fn choose_weighted<T:Copy>(&self, v : &[Weighted<T>]) -> T {
         self.choose_weighted_option(v).get()
     }
 
@@ -310,7 +310,7 @@ fn choose_weighted<T:Copy>(v : &[Weighted<T>]) -> T {
      * Choose Some(item) respecting the relative weights, returning none if
      * the sum of the weights is 0
      */
-    fn choose_weighted_option<T:Copy>(v: &[Weighted<T>]) -> Option<T> {
+    fn choose_weighted_option<T:Copy>(&self, v: &[Weighted<T>]) -> Option<T> {
         let mut total = 0u;
         for v.each |item| {
             total += item.weight;
@@ -333,7 +333,7 @@ fn choose_weighted_option<T:Copy>(v: &[Weighted<T>]) -> Option<T> {
      * Return a vec containing copies of the items, in order, where
      * the weight of the item determines how many copies there are
      */
-    fn weighted_vec<T:Copy>(v: &[Weighted<T>]) -> ~[T] {
+    fn weighted_vec<T:Copy>(&self, v: &[Weighted<T>]) -> ~[T] {
         let mut r = ~[];
         for v.each |item| {
             for uint::range(0u, item.weight) |_i| {
@@ -344,14 +344,14 @@ fn weighted_vec<T:Copy>(v: &[Weighted<T>]) -> ~[T] {
     }
 
     /// Shuffle a vec
-    fn shuffle<T:Copy>(values: &[T]) -> ~[T] {
+    fn shuffle<T:Copy>(&self, values: &[T]) -> ~[T] {
         let mut m = vec::from_slice(values);
         self.shuffle_mut(m);
         m
     }
 
     /// Shuffle a mutable vec in place
-    fn shuffle_mut<T>(values: &mut [T]) {
+    fn shuffle_mut<T>(&self, values: &mut [T]) {
         let mut i = values.len();
         while i >= 2u {
             // invariant: elements with index >= i have been locked in place.
@@ -382,7 +382,7 @@ fn RandRes(rng: *rust_rng) -> RandRes {
 }
 
 impl Rng for @RandRes {
-    fn next() -> u32 {
+    fn next(&self) -> u32 {
         unsafe {
             return rustrt::rand_next((*self).rng);
         }
@@ -432,7 +432,7 @@ struct XorShiftState {
 }
 
 impl Rng for XorShiftState {
-    fn next() -> u32 {
+    fn next(&self) -> u32 {
         let x = self.x;
         let mut t = x ^ (x << 11);
         self.x = self.y;
index 06ae4eb17a534614bee1fcc667230cc76942239b..f29447ef53e338e36191e28751e60920f175b45d 100644 (file)
@@ -26,9 +26,9 @@
  * then build a MovePtrAdaptor wrapped around your struct.
  */
 pub trait MovePtr {
-    fn move_ptr(adjustment: fn(*c_void) -> *c_void);
-    fn push_ptr();
-    fn pop_ptr();
+    fn move_ptr(&self, adjustment: fn(*c_void) -> *c_void);
+    fn push_ptr(&self);
+    fn pop_ptr(&self);
 }
 
 /// Helper function for alignment calculation.
@@ -47,26 +47,26 @@ pub fn MovePtrAdaptor<V:TyVisitor + MovePtr>(v: V) -> MovePtrAdaptor<V> {
 
 pub impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> {
     #[inline(always)]
-    fn bump(sz: uint) {
+    fn bump(&self, sz: uint) {
       do self.inner.move_ptr() |p| {
             ((p as uint) + sz) as *c_void
       };
     }
 
     #[inline(always)]
-    fn align(a: uint) {
+    fn align(&self, a: uint) {
       do self.inner.move_ptr() |p| {
             align(p as uint, a) as *c_void
       };
     }
 
     #[inline(always)]
-    fn align_to<T>() {
+    fn align_to<T>(&self) {
         self.align(sys::min_align_of::<T>());
     }
 
     #[inline(always)]
-    fn bump_past<T>() {
+    fn bump_past<T>(&self) {
         self.bump(sys::size_of::<T>());
     }
 }
index af135339b2e6f71cf3d00b19ede74680639fbb43..17d0cb4ea98fe34d398fb8e512a907385a1353dd 100644 (file)
 /// Helpers
 
 trait EscapedCharWriter {
-    fn write_escaped_char(ch: char);
+    fn write_escaped_char(&self, ch: char);
 }
 
 impl EscapedCharWriter for Writer {
-    fn write_escaped_char(ch: char) {
+    fn write_escaped_char(&self, ch: char) {
         match ch {
             '\t' => self.write_str("\\t"),
             '\r' => self.write_str("\\r"),
@@ -68,68 +68,76 @@ fn write_escaped_char(ch: char) {
 /// Representations
 
 trait Repr {
-    fn write_repr(writer: @Writer);
+    fn write_repr(&self, writer: @Writer);
 }
 
 impl Repr for () {
-    fn write_repr(writer: @Writer) { writer.write_str("()"); }
+    fn write_repr(&self, writer: @Writer) { writer.write_str("()"); }
 }
 
 impl Repr for bool {
-    fn write_repr(writer: @Writer) {
-        writer.write_str(if self { "true" } else { "false" })
+    fn write_repr(&self, writer: @Writer) {
+        writer.write_str(if *self { "true" } else { "false" })
     }
 }
 
 impl Repr for int {
-    fn write_repr(writer: @Writer) { writer.write_int(self); }
+    fn write_repr(&self, writer: @Writer) { writer.write_int(*self); }
 }
 impl Repr for i8 {
-    fn write_repr(writer: @Writer) { writer.write_int(self as int); }
+    fn write_repr(&self, writer: @Writer) { writer.write_int(*self as int); }
 }
 impl Repr for i16 {
-    fn write_repr(writer: @Writer) { writer.write_int(self as int); }
+    fn write_repr(&self, writer: @Writer) { writer.write_int(*self as int); }
 }
 impl Repr for i32 {
-    fn write_repr(writer: @Writer) { writer.write_int(self as int); }
+    fn write_repr(&self, writer: @Writer) { writer.write_int(*self as int); }
 }
 impl Repr for i64 {
     // FIXME #4424: This can lose precision.
-    fn write_repr(writer: @Writer) { writer.write_int(self as int); }
+    fn write_repr(&self, writer: @Writer) { writer.write_int(*self as int); }
 }
 
 impl Repr for uint {
-    fn write_repr(writer: @Writer) { writer.write_uint(self); }
+    fn write_repr(&self, writer: @Writer) { writer.write_uint(*self); }
 }
 impl Repr for u8 {
-    fn write_repr(writer: @Writer) { writer.write_uint(self as uint); }
+    fn write_repr(&self, writer: @Writer) {
+        writer.write_uint(*self as uint);
+    }
 }
 impl Repr for u16 {
-    fn write_repr(writer: @Writer) { writer.write_uint(self as uint); }
+    fn write_repr(&self, writer: @Writer) {
+        writer.write_uint(*self as uint);
+    }
 }
 impl Repr for u32 {
-    fn write_repr(writer: @Writer) { writer.write_uint(self as uint); }
+    fn write_repr(&self, writer: @Writer) {
+        writer.write_uint(*self as uint);
+    }
 }
 impl Repr for u64 {
     // FIXME #4424: This can lose precision.
-    fn write_repr(writer: @Writer) { writer.write_uint(self as uint); }
+    fn write_repr(&self, writer: @Writer) {
+        writer.write_uint(*self as uint);
+    }
 }
 
 impl Repr for float {
     // FIXME #4423: This mallocs.
-    fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); }
+    fn write_repr(&self, writer: @Writer) { writer.write_str(self.to_str()); }
 }
 impl Repr for f32 {
     // FIXME #4423 This mallocs.
-    fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); }
+    fn write_repr(&self, writer: @Writer) { writer.write_str(self.to_str()); }
 }
 impl Repr for f64 {
     // FIXME #4423: This mallocs.
-    fn write_repr(writer: @Writer) { writer.write_str(self.to_str()); }
+    fn write_repr(&self, writer: @Writer) { writer.write_str(self.to_str()); }
 }
 
 impl Repr for char {
-    fn write_repr(writer: @Writer) { writer.write_char(self); }
+    fn write_repr(&self, writer: @Writer) { writer.write_char(*self); }
 }
 
 
@@ -156,13 +164,13 @@ pub fn ReprVisitor(ptr: *c_void, writer: @Writer) -> ReprVisitor {
 
 impl MovePtr for ReprVisitor {
     #[inline(always)]
-    fn move_ptr(adjustment: fn(*c_void) -> *c_void) {
+    fn move_ptr(&self, adjustment: fn(*c_void) -> *c_void) {
         self.ptr = adjustment(self.ptr);
     }
-    fn push_ptr() {
+    fn push_ptr(&self) {
         self.ptr_stk.push(self.ptr);
     }
-    fn pop_ptr() {
+    fn pop_ptr(&self) {
         self.ptr = self.ptr_stk.pop();
     }
 }
@@ -172,7 +180,7 @@ pub impl ReprVisitor {
     // Various helpers for the TyVisitor impl
 
     #[inline(always)]
-    fn get<T>(f: fn(&T)) -> bool {
+    fn get<T>(&self, f: fn(&T)) -> bool {
         unsafe {
             f(transmute::<*c_void,&T>(copy self.ptr));
         }
@@ -180,24 +188,24 @@ fn get<T>(f: fn(&T)) -> bool {
     }
 
     #[inline(always)]
-    fn bump(sz: uint) {
+    fn bump(&self, sz: uint) {
       do self.move_ptr() |p| {
             ((p as uint) + sz) as *c_void
       };
     }
 
     #[inline(always)]
-    fn bump_past<T>() {
+    fn bump_past<T>(&self) {
         self.bump(sys::size_of::<T>());
     }
 
     #[inline(always)]
-    fn visit_inner(inner: *TyDesc) -> bool {
+    fn visit_inner(&self, inner: *TyDesc) -> bool {
         self.visit_ptr_inner(self.ptr, inner)
     }
 
     #[inline(always)]
-    fn visit_ptr_inner(ptr: *c_void, inner: *TyDesc) -> bool {
+    fn visit_ptr_inner(&self, ptr: *c_void, inner: *TyDesc) -> bool {
         unsafe {
             let mut u = ReprVisitor(ptr, self.writer);
             let v = reflect::MovePtrAdaptor(u);
@@ -207,13 +215,13 @@ fn visit_ptr_inner(ptr: *c_void, inner: *TyDesc) -> bool {
     }
 
     #[inline(always)]
-    fn write<T:Repr>() -> bool {
+    fn write<T:Repr>(&self) -> bool {
         do self.get |v:&T| {
             v.write_repr(self.writer);
         }
     }
 
-    fn write_escaped_slice(slice: &str) {
+    fn write_escaped_slice(&self, slice: &str) {
         self.writer.write_char('"');
         for str::chars_each(slice) |ch| {
             self.writer.write_escaped_char(ch);
@@ -221,7 +229,7 @@ fn write_escaped_slice(slice: &str) {
         self.writer.write_char('"');
     }
 
-    fn write_mut_qualifier(mtbl: uint) {
+    fn write_mut_qualifier(&self, mtbl: uint) {
         if mtbl == 0 {
             self.writer.write_str("mut ");
         } else if mtbl == 1 {
@@ -232,7 +240,7 @@ fn write_mut_qualifier(mtbl: uint) {
         }
     }
 
-    fn write_vec_range(mtbl: uint, ptr: *u8, len: uint,
+    fn write_vec_range(&self, mtbl: uint, ptr: *u8, len: uint,
                        inner: *TyDesc) -> bool {
         let mut p = ptr;
         let end = ptr::offset(p, len);
@@ -253,7 +261,7 @@ fn write_vec_range(mtbl: uint, ptr: *u8, len: uint,
         true
     }
 
-    fn write_unboxed_vec_repr(mtbl: uint, v: &UnboxedVecRepr,
+    fn write_unboxed_vec_repr(&self, mtbl: uint, v: &UnboxedVecRepr,
                               inner: *TyDesc) -> bool {
         self.write_vec_range(mtbl, ptr::to_unsafe_ptr(&v.data),
                              v.fill, inner)
index f1e23f01e7b51f53bbfff3b46f347bf20e84e68a..950c9627ec6b7515d1b161d682e155558543cbb9 100644 (file)
@@ -2198,22 +2198,22 @@ fn test_from_buf_len() {
 }
 
 pub trait Trimmable {
-    pure fn trim() -> Self;
-    pure fn trim_left() -> Self;
-    pure fn trim_right() -> Self;
+    pure fn trim(&self) -> Self;
+    pure fn trim_left(&self) -> Self;
+    pure fn trim_right(&self) -> Self;
 }
 
 /// Extension methods for strings
 impl Trimmable for ~str {
     /// Returns a string with leading and trailing whitespace removed
     #[inline]
-    pure fn trim() -> ~str { trim(self) }
+    pure fn trim(&self) -> ~str { trim(*self) }
     /// Returns a string with leading whitespace removed
     #[inline]
-    pure fn trim_left() -> ~str { trim_left(self) }
+    pure fn trim_left(&self) -> ~str { trim_left(*self) }
     /// Returns a string with trailing whitespace removed
     #[inline]
-    pure fn trim_right() -> ~str { trim_right(self) }
+    pure fn trim_right(&self) -> ~str { trim_right(*self) }
 }
 
 #[cfg(notest)]
@@ -2233,35 +2233,35 @@ impl Add<&str,~str> for ~str {
 pub mod traits {}
 
 pub trait StrSlice {
-    pure fn all(it: fn(char) -> bool) -> bool;
-    pure fn any(it: fn(char) -> bool) -> bool;
-    pure fn contains(needle: &a/str) -> bool;
-    pure fn contains_char(needle: char) -> bool;
-    pure fn each(it: fn(u8) -> bool);
-    pure fn eachi(it: fn(uint, u8) -> bool);
-    pure fn each_char(it: fn(char) -> bool);
-    pure fn each_chari(it: fn(uint, char) -> bool);
-    pure fn ends_with(needle: &str) -> bool;
-    pure fn is_empty() -> bool;
-    pure fn is_whitespace() -> bool;
-    pure fn is_alphanumeric() -> bool;
-    pure fn len() -> uint;
-    pure fn slice(begin: uint, end: uint) -> ~str;
-    pure fn split(sepfn: fn(char) -> bool) -> ~[~str];
-    pure fn split_char(sep: char) -> ~[~str];
-    pure fn split_str(sep: &a/str) -> ~[~str];
-    pure fn starts_with(needle: &a/str) -> bool;
-    pure fn substr(begin: uint, n: uint) -> ~str;
-    pure fn to_lower() -> ~str;
-    pure fn to_upper() -> ~str;
-    pure fn escape_default() -> ~str;
-    pure fn escape_unicode() -> ~str;
-    pure fn trim() -> ~str;
-    pure fn trim_left() -> ~str;
-    pure fn trim_right() -> ~str;
-    pure fn to_owned() -> ~str;
-    pure fn to_managed() -> @str;
-    pure fn char_at(i: uint) -> char;
+    pure fn all(&self, it: fn(char) -> bool) -> bool;
+    pure fn any(&self, it: fn(char) -> bool) -> bool;
+    pure fn contains(&self, needle: &a/str) -> bool;
+    pure fn contains_char(&self, needle: char) -> bool;
+    pure fn each(&self, it: fn(u8) -> bool);
+    pure fn eachi(&self, it: fn(uint, u8) -> bool);
+    pure fn each_char(&self, it: fn(char) -> bool);
+    pure fn each_chari(&self, it: fn(uint, char) -> bool);
+    pure fn ends_with(&self, needle: &str) -> bool;
+    pure fn is_empty(&self) -> bool;
+    pure fn is_whitespace(&self) -> bool;
+    pure fn is_alphanumeric(&self) -> bool;
+    pure fn len(&self) -> uint;
+    pure fn slice(&self, begin: uint, end: uint) -> ~str;
+    pure fn split(&self, sepfn: fn(char) -> bool) -> ~[~str];
+    pure fn split_char(&self, sep: char) -> ~[~str];
+    pure fn split_str(&self, sep: &a/str) -> ~[~str];
+    pure fn starts_with(&self, needle: &a/str) -> bool;
+    pure fn substr(&self, begin: uint, n: uint) -> ~str;
+    pure fn to_lower(&self) -> ~str;
+    pure fn to_upper(&self) -> ~str;
+    pure fn escape_default(&self) -> ~str;
+    pure fn escape_unicode(&self) -> ~str;
+    pure fn trim(&self) -> ~str;
+    pure fn trim_left(&self) -> ~str;
+    pure fn trim_right(&self) -> ~str;
+    pure fn to_owned(&self) -> ~str;
+    pure fn to_managed(&self) -> @str;
+    pure fn char_at(&self, i: uint) -> char;
 }
 
 /// Extension methods for strings
@@ -2271,56 +2271,62 @@ impl StrSlice for &str {
      * contains no characters
      */
     #[inline]
-    pure fn all(it: fn(char) -> bool) -> bool { all(self, it) }
+    pure fn all(&self, it: fn(char) -> bool) -> bool { all(*self, it) }
     /**
      * Return true if a predicate matches any character (and false if it
      * matches none or there are no characters)
      */
     #[inline]
-    pure fn any(it: fn(char) -> bool) -> bool { any(self, it) }
+    pure fn any(&self, it: fn(char) -> bool) -> bool { any(*self, it) }
     /// Returns true if one string contains another
     #[inline]
-    pure fn contains(needle: &a/str) -> bool { contains(self, needle) }
+    pure fn contains(&self, needle: &a/str) -> bool {
+        contains(*self, needle)
+    }
     /// Returns true if a string contains a char
     #[inline]
-    pure fn contains_char(needle: char) -> bool {
-        contains_char(self, needle)
+    pure fn contains_char(&self, needle: char) -> bool {
+        contains_char(*self, needle)
     }
     /// Iterate over the bytes in a string
     #[inline]
-    pure fn each(it: fn(u8) -> bool) { each(self, it) }
+    pure fn each(&self, it: fn(u8) -> bool) { each(*self, it) }
     /// Iterate over the bytes in a string, with indices
     #[inline]
-    pure fn eachi(it: fn(uint, u8) -> bool) { eachi(self, it) }
+    pure fn eachi(&self, it: fn(uint, u8) -> bool) { eachi(*self, it) }
     /// Iterate over the chars in a string
     #[inline]
-    pure fn each_char(it: fn(char) -> bool) { each_char(self, it) }
+    pure fn each_char(&self, it: fn(char) -> bool) { each_char(*self, it) }
     /// Iterate over the chars in a string, with indices
     #[inline]
-    pure fn each_chari(it: fn(uint, char) -> bool) { each_chari(self, it) }
+    pure fn each_chari(&self, it: fn(uint, char) -> bool) {
+        each_chari(*self, it)
+    }
     /// Returns true if one string ends with another
     #[inline]
-    pure fn ends_with(needle: &str) -> bool { ends_with(self, needle) }
+    pure fn ends_with(&self, needle: &str) -> bool {
+        ends_with(*self, needle)
+    }
     /// Returns true if the string has length 0
     #[inline]
-    pure fn is_empty() -> bool { is_empty(self) }
+    pure fn is_empty(&self) -> bool { is_empty(*self) }
     /**
      * Returns true if the string contains only whitespace
      *
      * Whitespace characters are determined by `char::is_whitespace`
      */
     #[inline]
-    pure fn is_whitespace() -> bool { is_whitespace(self) }
+    pure fn is_whitespace(&self) -> bool { is_whitespace(*self) }
     /**
      * Returns true if the string contains only alphanumerics
      *
      * Alphanumeric characters are determined by `char::is_alphanumeric`
      */
     #[inline]
-    pure fn is_alphanumeric() -> bool { is_alphanumeric(self) }
+    pure fn is_alphanumeric(&self) -> bool { is_alphanumeric(*self) }
     #[inline]
     /// Returns the size in bytes not counting the null terminator
-    pure fn len() -> uint { len(self) }
+    pure fn len(&self) -> uint { len(*self) }
     /**
      * Returns a slice of the given string from the byte range
      * [`begin`..`end`)
@@ -2329,24 +2335,30 @@ impl StrSlice for &str {
      * beyond the last character of the string
      */
     #[inline]
-    pure fn slice(begin: uint, end: uint) -> ~str { slice(self, begin, end) }
+    pure fn slice(&self, begin: uint, end: uint) -> ~str {
+        slice(*self, begin, end)
+    }
     /// Splits a string into substrings using a character function
     #[inline]
-    pure fn split(sepfn: fn(char) -> bool) -> ~[~str] { split(self, sepfn) }
+    pure fn split(&self, sepfn: fn(char) -> bool) -> ~[~str] {
+        split(*self, sepfn)
+    }
     /**
      * Splits a string into substrings at each occurrence of a given character
      */
     #[inline]
-    pure fn split_char(sep: char) -> ~[~str] { split_char(self, sep) }
+    pure fn split_char(&self, sep: char) -> ~[~str] { split_char(*self, sep) }
     /**
      * Splits a string into a vector of the substrings separated by a given
      * string
      */
     #[inline]
-    pure fn split_str(sep: &a/str) -> ~[~str] { split_str(self, sep) }
+    pure fn split_str(&self, sep: &a/str) -> ~[~str] { split_str(*self, sep) }
     /// Returns true if one string starts with another
     #[inline]
-    pure fn starts_with(needle: &a/str) -> bool { starts_with(self, needle) }
+    pure fn starts_with(&self, needle: &a/str) -> bool {
+        starts_with(*self, needle)
+    }
     /**
      * Take a substring of another.
      *
@@ -2354,35 +2366,37 @@ impl StrSlice for &str {
      * `begin`.
      */
     #[inline]
-    pure fn substr(begin: uint, n: uint) -> ~str { substr(self, begin, n) }
+    pure fn substr(&self, begin: uint, n: uint) -> ~str {
+        substr(*self, begin, n)
+    }
     /// Convert a string to lowercase
     #[inline]
-    pure fn to_lower() -> ~str { to_lower(self) }
+    pure fn to_lower(&self) -> ~str { to_lower(*self) }
     /// Convert a string to uppercase
     #[inline]
-    pure fn to_upper() -> ~str { to_upper(self) }
+    pure fn to_upper(&self) -> ~str { to_upper(*self) }
     /// Escape each char in `s` with char::escape_default.
     #[inline]
-    pure fn escape_default() -> ~str { escape_default(self) }
+    pure fn escape_default(&self) -> ~str { escape_default(*self) }
     /// Escape each char in `s` with char::escape_unicode.
     #[inline]
-    pure fn escape_unicode() -> ~str { escape_unicode(self) }
+    pure fn escape_unicode(&self) -> ~str { escape_unicode(*self) }
 
     /// Returns a string with leading and trailing whitespace removed
     #[inline]
-    pure fn trim() -> ~str { trim(self) }
+    pure fn trim(&self) -> ~str { trim(*self) }
     /// Returns a string with leading whitespace removed
     #[inline]
-    pure fn trim_left() -> ~str { trim_left(self) }
+    pure fn trim_left(&self) -> ~str { trim_left(*self) }
     /// Returns a string with trailing whitespace removed
     #[inline]
-    pure fn trim_right() -> ~str { trim_right(self) }
+    pure fn trim_right(&self) -> ~str { trim_right(*self) }
 
     #[inline]
-    pure fn to_owned() -> ~str { self.slice(0, self.len()) }
+    pure fn to_owned(&self) -> ~str { self.slice(0, self.len()) }
 
     #[inline]
-    pure fn to_managed() -> @str {
+    pure fn to_managed(&self) -> @str {
         let v = at_vec::from_fn(self.len() + 1, |i| {
             if i == self.len() { 0 } else { self[i] }
         });
@@ -2390,7 +2404,7 @@ impl StrSlice for &str {
     }
 
     #[inline]
-    pure fn char_at(i: uint) -> char { char_at(self, i) }
+    pure fn char_at(&self, i: uint) -> char { char_at(*self, i) }
 }
 
 pub trait OwnedStr {
index 0835d4400ede80b54d708277f59a6d20690ee1f2..4a9d4056cab878275f4da91a0c9e988bcee1414c 100644 (file)
@@ -212,7 +212,7 @@ pub fn task() -> TaskBuilder {
 
 #[doc(hidden)] // FIXME #3538
 priv impl TaskBuilder {
-    fn consume() -> TaskBuilder {
+    fn consume(&self) -> TaskBuilder {
         if self.consumed {
             fail!(~"Cannot copy a task_builder"); // Fake move mode on self
         }
@@ -237,7 +237,7 @@ pub impl TaskBuilder {
      * Decouple the child task's failure from the parent's. If either fails,
      * the other will not be killed.
      */
-    fn unlinked() -> TaskBuilder {
+    fn unlinked(&self) -> TaskBuilder {
         let notify_chan = replace(&mut self.opts.notify_chan, None);
         TaskBuilder {
             opts: TaskOpts {
@@ -255,7 +255,7 @@ fn unlinked() -> TaskBuilder {
      * child's failure will not kill the parent, but the parent's will kill
      * the child.
      */
-    fn supervised() -> TaskBuilder {
+    fn supervised(&self) -> TaskBuilder {
         let notify_chan = replace(&mut self.opts.notify_chan, None);
         TaskBuilder {
             opts: TaskOpts {
@@ -272,7 +272,7 @@ fn supervised() -> TaskBuilder {
      * Link the child task's and parent task's failures. If either fails, the
      * other will be killed.
      */
-    fn linked() -> TaskBuilder {
+    fn linked(&self) -> TaskBuilder {
         let notify_chan = replace(&mut self.opts.notify_chan, None);
         TaskBuilder {
             opts: TaskOpts {
@@ -303,7 +303,7 @@ fn linked() -> TaskBuilder {
      * # Failure
      * Fails if a future_result was already set for this task.
      */
-    fn future_result(blk: fn(v: Port<TaskResult>)) -> TaskBuilder {
+    fn future_result(&self, blk: fn(v: Port<TaskResult>)) -> TaskBuilder {
         // FIXME (#3725): Once linked failure and notification are
         // handled in the library, I can imagine implementing this by just
         // registering an arbitrary number of task::on_exit handlers and
@@ -331,7 +331,7 @@ fn future_result(blk: fn(v: Port<TaskResult>)) -> TaskBuilder {
         }
     }
     /// Configure a custom scheduler mode for the task.
-    fn sched_mode(mode: SchedMode) -> TaskBuilder {
+    fn sched_mode(&self, mode: SchedMode) -> TaskBuilder {
         let notify_chan = replace(&mut self.opts.notify_chan, None);
         TaskBuilder {
             opts: TaskOpts {
@@ -357,7 +357,7 @@ fn sched_mode(mode: SchedMode) -> TaskBuilder {
      * generator by applying the task body which results from the
      * existing body generator to the new body generator.
      */
-    fn add_wrapper(wrapper: @fn(v: ~fn()) -> ~fn()) -> TaskBuilder {
+    fn add_wrapper(&self, wrapper: @fn(v: ~fn()) -> ~fn()) -> TaskBuilder {
         let prev_gen_body = self.gen_body;
         let notify_chan = replace(&mut self.opts.notify_chan, None);
         TaskBuilder {
@@ -385,7 +385,7 @@ fn add_wrapper(wrapper: @fn(v: ~fn()) -> ~fn()) -> TaskBuilder {
      * When spawning into a new scheduler, the number of threads requested
      * must be greater than zero.
      */
-    fn spawn(f: ~fn()) {
+    fn spawn(&self, f: ~fn()) {
         let notify_chan = replace(&mut self.opts.notify_chan, None);
         let x = self.consume();
         let opts = TaskOpts {
@@ -397,7 +397,7 @@ fn spawn(f: ~fn()) {
         spawn::spawn_raw(opts, (x.gen_body)(f));
     }
     /// Runs a task, while transfering ownership of one argument to the child.
-    fn spawn_with<A:Owned>(arg: A, f: ~fn(v: A)) {
+    fn spawn_with<A:Owned>(&self, arg: A, f: ~fn(v: A)) {
         let arg = Cell(arg);
         do self.spawn {
             f(arg.take());
@@ -417,7 +417,7 @@ fn spawn_with<A:Owned>(arg: A, f: ~fn(v: A)) {
      * # Failure
      * Fails if a future_result was already set for this task.
      */
-    fn try<T:Owned>(f: ~fn() -> T) -> Result<T,()> {
+    fn try<T:Owned>(&self, f: ~fn() -> T) -> Result<T,()> {
         let (po, ch) = stream::<T>();
         let mut result = None;
 
index dde7d718c13d5d41d8213933ca0c97d0daceb946..faa2636ed4e8b1c1a112021b0c617e7347a821df 100644 (file)
 use vec;
 
 pub trait CopyableTuple<T, U> {
-    pure fn first() -> T;
-    pure fn second() -> U;
-    pure fn swap() -> (U, T);
+    pure fn first(&self) -> T;
+    pure fn second(&self) -> U;
+    pure fn swap(&self) -> (U, T);
 }
 
 impl<T:Copy,U:Copy> CopyableTuple<T, U> for (T, U) {
 
     /// Return the first element of self
     #[inline(always)]
-    pure fn first() -> T {
-        let (t, _) = self;
+    pure fn first(&self) -> T {
+        let (t, _) = *self;
         return t;
     }
 
     /// Return the second element of self
     #[inline(always)]
-    pure fn second() -> U {
-        let (_, u) = self;
+    pure fn second(&self) -> U {
+        let (_, u) = *self;
         return u;
     }
 
     /// Return the results of swapping the two elements of self
     #[inline(always)]
-    pure fn swap() -> (U, T) {
-        let (t, u) = self;
+    pure fn swap(&self) -> (U, T) {
+        let (t, u) = *self;
         return (u, t);
     }
 
index 616d37a133a9f18af4e6b5fba03105a5754c3cc0..bfbd1669341c35c2caa3a042085eba0ee4b707d9 100644 (file)
@@ -143,7 +143,7 @@ struct Parsed<T> {
     }
 
     pub impl<T> Parsed<T> {
-        static pure fn new(val: T, next: uint) -> Parsed<T> {
+        static pure fn new(&self, val: T, next: uint) -> Parsed<T> {
             Parsed {val: val, next: next}
         }
     }
index 02875739ebaf933dff268146a845d7c5501b3f54..14a37ecbf520fffc99995740dc4c3d1078ec764e 100644 (file)
@@ -26,35 +26,35 @@ pub struct DuplexStream<T, U> {
 }
 
 impl<T:Owned,U:Owned> GenericChan<T> for DuplexStream<T, U> {
-    fn send(x: T) {
+    fn send(&self, x: T) {
         self.chan.send(x)
     }
 }
 
 impl<T:Owned,U:Owned> GenericSmartChan<T> for DuplexStream<T, U> {
-    fn try_send(x: T) -> bool {
+    fn try_send(&self, x: T) -> bool {
         self.chan.try_send(x)
     }
 }
 
 impl<T:Owned,U:Owned> GenericPort<U> for DuplexStream<T, U> {
-    fn recv() -> U {
+    fn recv(&self) -> U {
         self.port.recv()
     }
 
-    fn try_recv() -> Option<U> {
+    fn try_recv(&self) -> Option<U> {
         self.port.try_recv()
     }
 }
 
 impl<T:Owned,U:Owned> Peekable<U> for DuplexStream<T, U> {
-    pure fn peek() -> bool {
+    pure fn peek(&self) -> bool {
         self.port.peek()
     }
 }
 
 impl<T:Owned,U:Owned> Selectable for DuplexStream<T, U> {
-    pure fn header() -> *pipes::PacketHeader {
+    pure fn header(&self) -> *pipes::PacketHeader {
         self.port.header()
     }
 }
index 42f954f7c390d08e9a3ea570ee6a49ea251b4682..b89396436c54e1968d6a6f15d5e6609462ede340 100644 (file)
@@ -259,13 +259,13 @@ pub trait ByteChan {
 const CONTINUE: [u8 * 4] = [0xAA, 0xBB, 0xCC, 0xDD];
 
 impl<T,U:Unflattener<T>,P:BytePort> GenericPort<T> for FlatPort<T, U, P> {
-    fn recv() -> T {
+    fn recv(&self) -> T {
         match self.try_recv() {
             Some(val) => val,
             None => fail!(~"port is closed")
         }
     }
-    fn try_recv() -> Option<T> {
+    fn try_recv(&self) -> Option<T> {
         let command = match self.byte_port.try_recv(CONTINUE.len()) {
             Some(c) => c,
             None => {
@@ -304,7 +304,7 @@ fn try_recv() -> Option<T> {
 }
 
 impl<T,F:Flattener<T>,C:ByteChan> GenericChan<T> for FlatChan<T, F, C> {
-    fn send(val: T) {
+    fn send(&self, val: T) {
         self.byte_chan.send(CONTINUE.to_vec());
         let bytes = self.flattener.flatten(val);
         let len = bytes.len() as u64;