diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-05-31 15:17:22 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-06-01 09:18:27 -0700 |
| commit | 5fb254695b4db9af3d8e33577fae28ae9f7006c5 (patch) | |
| tree | 33a4db59bd936a73594ca144e809b6074d6ccef3 /src/libstd | |
| parent | 1e52eede31a1df3627bfa9f43b9d06c730895c01 (diff) | |
| download | rust-5fb254695b4db9af3d8e33577fae28ae9f7006c5.tar.gz rust-5fb254695b4db9af3d8e33577fae28ae9f7006c5.zip | |
Remove all uses of `pub impl`. rs=style
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/cell.rs | 18 | ||||
| -rw-r--r-- | src/libstd/comm.rs | 24 | ||||
| -rw-r--r-- | src/libstd/condition.rs | 12 | ||||
| -rw-r--r-- | src/libstd/either.rs | 18 | ||||
| -rw-r--r-- | src/libstd/hashmap.rs | 50 | ||||
| -rw-r--r-- | src/libstd/option.rs | 58 | ||||
| -rw-r--r-- | src/libstd/path.rs | 32 | ||||
| -rw-r--r-- | src/libstd/pipes.rs | 24 | ||||
| -rw-r--r-- | src/libstd/rand.rs | 22 | ||||
| -rw-r--r-- | src/libstd/reflect.rs | 18 | ||||
| -rw-r--r-- | src/libstd/repr.rs | 32 | ||||
| -rw-r--r-- | src/libstd/result.rs | 34 | ||||
| -rw-r--r-- | src/libstd/rt/context.rs | 8 | ||||
| -rw-r--r-- | src/libstd/rt/sched.rs | 51 | ||||
| -rw-r--r-- | src/libstd/rt/stack.rs | 10 | ||||
| -rw-r--r-- | src/libstd/rt/thread.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rt/uv/idle.rs | 15 | ||||
| -rw-r--r-- | src/libstd/rt/uv/mod.rs | 17 | ||||
| -rw-r--r-- | src/libstd/rt/uv/net.rs | 34 | ||||
| -rw-r--r-- | src/libstd/rt/uv/uvio.rs | 11 | ||||
| -rw-r--r-- | src/libstd/rt/uvio.rs | 10 | ||||
| -rw-r--r-- | src/libstd/rt/work_queue.rs | 12 | ||||
| -rw-r--r-- | src/libstd/run.rs | 43 | ||||
| -rw-r--r-- | src/libstd/str/ascii.rs | 14 | ||||
| -rw-r--r-- | src/libstd/task/mod.rs | 22 | ||||
| -rw-r--r-- | src/libstd/trie.rs | 24 | ||||
| -rw-r--r-- | src/libstd/unstable/extfmt.rs | 4 | ||||
| -rw-r--r-- | src/libstd/unstable/sync.rs | 10 | ||||
| -rw-r--r-- | src/libstd/util.rs | 4 |
29 files changed, 329 insertions, 306 deletions
diff --git a/src/libstd/cell.rs b/src/libstd/cell.rs index 87145acbb62..ab4752ff847 100644 --- a/src/libstd/cell.rs +++ b/src/libstd/cell.rs @@ -10,6 +10,8 @@ //! A mutable, nullable memory location +#[missing_doc]; + use cast::transmute_mut; use prelude::*; use util::replace; @@ -37,9 +39,9 @@ pub fn empty_cell<T>() -> Cell<T> { Cell { value: None } } -pub impl<T> Cell<T> { +impl<T> Cell<T> { /// Yields the value, failing if the cell is empty. - fn take(&self) -> T { + pub fn take(&self) -> T { let this = unsafe { transmute_mut(self) }; if this.is_empty() { fail!("attempt to take an empty cell"); @@ -49,7 +51,7 @@ pub impl<T> Cell<T> { } /// Returns the value, failing if the cell is full. - fn put_back(&self, value: T) { + pub fn put_back(&self, value: T) { let this = unsafe { transmute_mut(self) }; if !this.is_empty() { fail!("attempt to put a value back into a full cell"); @@ -58,20 +60,20 @@ pub impl<T> Cell<T> { } /// Returns true if the cell is empty and false if the cell is full. - fn is_empty(&self) -> bool { + pub fn is_empty(&self) -> bool { self.value.is_none() } - // Calls a closure with a reference to the value. - fn with_ref<R>(&self, op: &fn(v: &T) -> R) -> R { + /// Calls a closure with a reference to the value. + pub fn with_ref<R>(&self, op: &fn(v: &T) -> R) -> R { let v = self.take(); let r = op(&v); self.put_back(v); r } - // Calls a closure with a mutable reference to the value. - fn with_mut_ref<R>(&self, op: &fn(v: &mut T) -> R) -> R { + /// Calls a closure with a mutable reference to the value. + pub fn with_mut_ref<R>(&self, op: &fn(v: &mut T) -> R) -> R { let mut v = self.take(); let r = op(&mut v); self.put_back(v); diff --git a/src/libstd/comm.rs b/src/libstd/comm.rs index e044a73b338..a376a715976 100644 --- a/src/libstd/comm.rs +++ b/src/libstd/comm.rs @@ -150,14 +150,14 @@ pub struct PortSet<T> { ports: ~[pipesy::Port<T>], } -pub impl<T: Owned> PortSet<T> { - fn new() -> PortSet<T> { +impl<T: Owned> PortSet<T> { + pub fn new() -> PortSet<T> { PortSet { ports: ~[] } } - fn add(&self, port: Port<T>) { + pub fn add(&self, port: Port<T>) { let Port { inner } = port; let port = match inner { Left(p) => p, @@ -169,7 +169,7 @@ pub impl<T: Owned> PortSet<T> { } } - fn chan(&self) -> Chan<T> { + pub fn chan(&self) -> Chan<T> { let (po, ch) = stream(); self.add(po); ch @@ -470,20 +470,20 @@ mod pipesy { (PortOne::new(port), ChanOne::new(chan)) } - pub impl<T: Owned> PortOne<T> { - fn recv(self) -> T { recv_one(self) } - fn try_recv(self) -> Option<T> { try_recv_one(self) } - fn unwrap(self) -> oneshot::server::Oneshot<T> { + impl<T: Owned> PortOne<T> { + pub fn recv(self) -> T { recv_one(self) } + pub fn try_recv(self) -> Option<T> { try_recv_one(self) } + pub fn unwrap(self) -> oneshot::server::Oneshot<T> { match self { PortOne { contents: s } => s } } } - pub impl<T: Owned> ChanOne<T> { - fn send(self, data: T) { send_one(self, data) } - fn try_send(self, data: T) -> bool { try_send_one(self, data) } - fn unwrap(self) -> oneshot::client::Oneshot<T> { + impl<T: Owned> ChanOne<T> { + pub fn send(self, data: T) { send_one(self, data) } + pub fn try_send(self, data: T) -> bool { try_send_one(self, data) } + pub fn unwrap(self) -> oneshot::client::Oneshot<T> { match self { ChanOne { contents: s } => s } diff --git a/src/libstd/condition.rs b/src/libstd/condition.rs index eed61aab5c0..2f150a0d1b2 100644 --- a/src/libstd/condition.rs +++ b/src/libstd/condition.rs @@ -29,8 +29,8 @@ pub struct Condition<'self, T, U> { key: local_data::LocalDataKey<'self, Handler<T, U>> } -pub impl<'self, T, U> Condition<'self, T, U> { - fn trap(&'self self, h: &'self fn(T) -> U) -> Trap<'self, T, U> { +impl<'self, T, U> Condition<'self, T, U> { + pub fn trap(&'self self, h: &'self fn(T) -> U) -> Trap<'self, T, U> { unsafe { let p : *RustClosure = ::cast::transmute(&h); let prev = local_data::local_data_get(self.key); @@ -39,12 +39,12 @@ pub impl<'self, T, U> Condition<'self, T, U> { } } - fn raise(&self, t: T) -> U { + pub 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(&self, t: T, default: &fn() -> U) -> U { + pub fn raise_default(&self, t: T, default: &fn() -> U) -> U { unsafe { match local_data_pop(self.key) { None => { @@ -73,8 +73,8 @@ struct Trap<'self, T, U> { handler: @Handler<T, U> } -pub impl<'self, T, U> Trap<'self, T, U> { - fn in<V>(&self, inner: &'self fn() -> V) -> V { +impl<'self, T, U> Trap<'self, T, U> { + pub fn in<V>(&self, inner: &'self fn() -> V) -> V { unsafe { let _g = Guard { cond: self.cond }; debug!("Trap: pushing handler to TLS"); diff --git a/src/libstd/either.rs b/src/libstd/either.rs index f89bb3b2f90..fac0866f17e 100644 --- a/src/libstd/either.rs +++ b/src/libstd/either.rs @@ -10,6 +10,8 @@ //! A type that represents one of two alternatives +#[allow(missing_doc)]; + use container::Container; use cmp::Eq; use kinds::Copy; @@ -137,29 +139,29 @@ pub fn unwrap_right<T,U>(eith: Either<T,U>) -> U { } } -pub impl<T, U> Either<T, U> { +impl<T, U> Either<T, U> { #[inline(always)] - fn either<V>(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V { + pub fn either<V>(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V { either(f_left, f_right, self) } #[inline(always)] - fn flip(self) -> Either<U, T> { flip(self) } + pub fn flip(self) -> Either<U, T> { flip(self) } #[inline(always)] - fn to_result(self) -> Result<U, T> { to_result(self) } + pub fn to_result(self) -> Result<U, T> { to_result(self) } #[inline(always)] - fn is_left(&self) -> bool { is_left(self) } + pub fn is_left(&self) -> bool { is_left(self) } #[inline(always)] - fn is_right(&self) -> bool { is_right(self) } + pub fn is_right(&self) -> bool { is_right(self) } #[inline(always)] - fn unwrap_left(self) -> T { unwrap_left(self) } + pub fn unwrap_left(self) -> T { unwrap_left(self) } #[inline(always)] - fn unwrap_right(self) -> U { unwrap_right(self) } + pub fn unwrap_right(self) -> U { unwrap_right(self) } } #[test] diff --git a/src/libstd/hashmap.rs b/src/libstd/hashmap.rs index 4826af20c69..2d56707e2f6 100644 --- a/src/libstd/hashmap.rs +++ b/src/libstd/hashmap.rs @@ -13,6 +13,8 @@ //! The tables use a keyed hash with new random keys generated for each container, so the ordering //! of a set of keys in a hash table is randomized. +#[mutable_doc]; + use container::{Container, Mutable, Map, Set}; use cmp::{Eq, Equiv}; use hash::Hash; @@ -81,7 +83,7 @@ fn linear_map_with_capacity_and_keys<K:Eq + Hash,V>( } } -priv impl<K:Hash + Eq,V> HashMap<K, V> { +impl<K:Hash + Eq,V> HashMap<K, V> { #[inline(always)] fn to_bucket(&self, h: uint) -> uint { // A good hash function with entropy spread over all of the @@ -403,20 +405,20 @@ impl<K:Hash + Eq,V> Map<K, V> for HashMap<K, V> { } } -pub impl<K: Hash + Eq, V> HashMap<K, V> { +impl<K: Hash + Eq, V> HashMap<K, V> { /// Create an empty HashMap - fn new() -> HashMap<K, V> { + pub fn new() -> HashMap<K, V> { HashMap::with_capacity(INITIAL_CAPACITY) } /// Create an empty HashMap with space for at least `n` elements in /// the hash table. - fn with_capacity(capacity: uint) -> HashMap<K, V> { + pub fn with_capacity(capacity: uint) -> HashMap<K, V> { linear_map_with_capacity(capacity) } /// Reserve space for at least `n` elements in the hash table. - fn reserve_at_least(&mut self, n: uint) { + pub fn reserve_at_least(&mut self, n: uint) { if n > self.buckets.len() { let buckets = n * 4 / 3 + 1; self.resize(uint::next_power_of_two(buckets)); @@ -425,7 +427,7 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { /// Return the value corresponding to the key in the map, or insert /// and return the value if it doesn't exist. - fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V { + pub fn find_or_insert<'a>(&'a mut self, k: K, v: V) -> &'a V { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so // that we do not resize if this call to insert is @@ -453,7 +455,8 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { /// Return the value corresponding to the key in the map, or create, /// insert, and return a new value if it doesn't exist. - fn find_or_insert_with<'a>(&'a mut self, k: K, f: &fn(&K) -> V) -> &'a V { + pub fn find_or_insert_with<'a>(&'a mut self, k: K, f: &fn(&K) -> V) + -> &'a V { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so // that we do not resize if this call to insert is @@ -480,7 +483,9 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { self.value_for_bucket(idx) } - fn consume(&mut self, f: &fn(K, V)) { + /// Calls a function on each element of a hash map, destroying the hash + /// map in the process. + pub fn consume(&mut self, f: &fn(K, V)) { let buckets = replace(&mut self.buckets, vec::from_fn(INITIAL_CAPACITY, |_| None)); self.size = 0; @@ -495,7 +500,9 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { } } - fn get<'a>(&'a self, k: &K) -> &'a V { + /// Retrieves a value for the given key, failing if the key is not + /// present. + pub fn get<'a>(&'a self, k: &K) -> &'a V { match self.find(k) { Some(v) => v, None => fail!("No entry found for key: %?", k), @@ -504,7 +511,7 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { /// Return true if the map contains a value for the specified key, /// using equivalence - fn contains_key_equiv<Q:Hash + Equiv<K>>(&self, key: &Q) -> bool { + pub fn contains_key_equiv<Q:Hash + Equiv<K>>(&self, key: &Q) -> bool { match self.bucket_for_key_equiv(key) { FoundEntry(_) => {true} TableFull | FoundHole(_) => {false} @@ -513,7 +520,8 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { /// Return the value corresponding to the key in the map, using /// equivalence - fn find_equiv<'a, Q:Hash + Equiv<K>>(&'a self, k: &Q) -> Option<&'a V> { + pub fn find_equiv<'a, Q:Hash + Equiv<K>>(&'a self, k: &Q) + -> Option<&'a V> { match self.bucket_for_key_equiv(k) { FoundEntry(idx) => Some(self.value_for_bucket(idx)), TableFull | FoundHole(_) => None, @@ -521,14 +529,14 @@ pub impl<K: Hash + Eq, V> HashMap<K, V> { } } -pub impl<K: Hash + Eq, V: Copy> HashMap<K, V> { +impl<K: Hash + Eq, V: Copy> HashMap<K, V> { /// Like `find`, but returns a copy of the value. - fn find_copy(&self, k: &K) -> Option<V> { + pub fn find_copy(&self, k: &K) -> Option<V> { self.find(k).map_consume(|v| copy *v) } /// Like `get`, but returns a copy of the value. - fn get_copy(&self, k: &K) -> V { + pub fn get_copy(&self, k: &K) -> V { copy *self.get(k) } } @@ -632,29 +640,31 @@ impl<T:Hash + Eq> Set<T> for HashSet<T> { } } -pub impl <T:Hash + Eq> HashSet<T> { +impl<T:Hash + Eq> HashSet<T> { /// Create an empty HashSet - fn new() -> HashSet<T> { + pub fn new() -> HashSet<T> { HashSet::with_capacity(INITIAL_CAPACITY) } /// Create an empty HashSet with space for at least `n` elements in /// the hash table. - fn with_capacity(capacity: uint) -> HashSet<T> { + pub fn with_capacity(capacity: uint) -> HashSet<T> { HashSet { map: HashMap::with_capacity(capacity) } } /// Reserve space for at least `n` elements in the hash table. - fn reserve_at_least(&mut self, n: uint) { + pub fn reserve_at_least(&mut self, n: uint) { self.map.reserve_at_least(n) } /// Consumes all of the elements in the set, emptying it out - fn consume(&mut self, f: &fn(T)) { + pub fn consume(&mut self, f: &fn(T)) { self.map.consume(|k, _| f(k)) } - fn contains_equiv<Q:Hash + Equiv<T>>(&self, value: &Q) -> bool { + /// Returns true if the hash set contains a value equivalent to the + /// given query value. + pub fn contains_equiv<Q:Hash + Equiv<T>>(&self, value: &Q) -> bool { self.map.contains_key_equiv(value) } } diff --git a/src/libstd/option.rs b/src/libstd/option.rs index ee6e37aeb78..b9d04edd8a3 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -145,21 +145,20 @@ impl<A> ExtendedIter<A> for Option<A> { } } -pub impl<T> Option<T> { +impl<T> Option<T> { /// Returns true if the option equals `none` - fn is_none(&const self) -> bool { + pub fn is_none(&const self) -> bool { match *self { None => true, Some(_) => false } } /// Returns true if the option contains some value #[inline(always)] - fn is_some(&const self) -> bool { !self.is_none() } + pub fn is_some(&const self) -> bool { !self.is_none() } /// Update an optional value by optionally running its content through a /// function that returns an option. #[inline(always)] - fn chain<U>(self, f: &fn(t: T) -> Option<U>) -> Option<U> { - + pub fn chain<U>(self, f: &fn(t: T) -> Option<U>) -> Option<U> { match self { Some(t) => f(t), None => None @@ -168,7 +167,7 @@ pub impl<T> Option<T> { /// Returns the leftmost Some() value, or None if both are None. #[inline(always)] - fn or(self, optb: Option<T>) -> Option<T> { + pub fn or(self, optb: Option<T>) -> Option<T> { match self { Some(opta) => Some(opta), _ => optb @@ -178,45 +177,49 @@ pub impl<T> Option<T> { /// Update an optional value by optionally running its content by reference /// through a function that returns an option. #[inline(always)] - fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option<U>) -> Option<U> { - match *self { Some(ref x) => f(x), None => None } + pub fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option<U>) + -> Option<U> { + match *self { + Some(ref x) => f(x), + None => None + } } /// Maps a `some` value from one type to another by reference #[inline(always)] - fn map<'a, U>(&self, f: &fn(&'a T) -> U) -> Option<U> { + pub fn map<'a, U>(&self, f: &fn(&'a T) -> U) -> Option<U> { match *self { Some(ref x) => Some(f(x)), None => None } } /// As `map`, but consumes the option and gives `f` ownership to avoid /// copying. #[inline(always)] - fn map_consume<U>(self, f: &fn(v: T) -> U) -> Option<U> { + pub fn map_consume<U>(self, f: &fn(v: T) -> U) -> Option<U> { match self { None => None, Some(v) => Some(f(v)) } } /// Applies a function to the contained value or returns a default #[inline(always)] - fn map_default<'a, U>(&'a self, def: U, f: &fn(&'a T) -> U) -> U { + pub fn map_default<'a, U>(&'a self, def: U, f: &fn(&'a T) -> U) -> U { match *self { None => def, Some(ref t) => f(t) } } /// As `map_default`, but consumes the option and gives `f` /// ownership to avoid copying. #[inline(always)] - fn map_consume_default<U>(self, def: U, f: &fn(v: T) -> U) -> U { + pub fn map_consume_default<U>(self, def: U, f: &fn(v: T) -> U) -> U { match self { None => def, Some(v) => f(v) } } /// Apply a function to the contained value or do nothing - fn mutate(&mut self, f: &fn(T) -> T) { + pub fn mutate(&mut self, f: &fn(T) -> T) { if self.is_some() { *self = Some(f(self.swap_unwrap())); } } /// Apply a function to the contained value or set it to a default - fn mutate_default(&mut self, def: T, f: &fn(T) -> T) { + pub fn mutate_default(&mut self, def: T, f: &fn(T) -> T) { if self.is_some() { *self = Some(f(self.swap_unwrap())); } else { @@ -239,7 +242,7 @@ pub impl<T> Option<T> { case explicitly. */ #[inline(always)] - fn get_ref<'a>(&'a self) -> &'a T { + pub fn get_ref<'a>(&'a self) -> &'a T { match *self { Some(ref x) => x, None => fail!("option::get_ref none") @@ -261,7 +264,7 @@ pub impl<T> Option<T> { case explicitly. */ #[inline(always)] - fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { + pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { match *self { Some(ref mut x) => x, None => fail!("option::get_mut_ref none") @@ -269,7 +272,7 @@ pub impl<T> Option<T> { } #[inline(always)] - fn unwrap(self) -> T { + pub fn unwrap(self) -> T { /*! Moves a value out of an option type and returns it. @@ -301,7 +304,7 @@ pub impl<T> Option<T> { * Fails if the value equals `None`. */ #[inline(always)] - fn swap_unwrap(&mut self) -> T { + pub fn swap_unwrap(&mut self) -> T { if self.is_none() { fail!("option::swap_unwrap none") } util::replace(self, None).unwrap() } @@ -315,7 +318,7 @@ pub impl<T> Option<T> { * Fails if the value equals `none` */ #[inline(always)] - fn expect(self, reason: &str) -> T { + pub fn expect(self, reason: &str) -> T { match self { Some(val) => val, None => fail!(reason.to_owned()), @@ -323,7 +326,7 @@ pub impl<T> Option<T> { } } -pub impl<T:Copy> Option<T> { +impl<T:Copy> Option<T> { /** Gets the value out of an option @@ -339,7 +342,7 @@ pub impl<T:Copy> Option<T> { case explicitly. */ #[inline(always)] - fn get(self) -> T { + pub fn get(self) -> T { match self { Some(x) => return x, None => fail!("option::get none") @@ -348,13 +351,13 @@ pub impl<T:Copy> Option<T> { /// Returns the contained value or a default #[inline(always)] - fn get_or_default(self, def: T) -> T { + pub fn get_or_default(self, def: T) -> T { match self { Some(x) => x, None => def } } /// Applies a function zero or more times until the result is none. #[inline(always)] - fn while_some(self, blk: &fn(v: T) -> Option<T>) { + pub fn while_some(self, blk: &fn(v: T) -> Option<T>) { let mut opt = self; while opt.is_some() { opt = blk(opt.unwrap()); @@ -362,11 +365,14 @@ pub impl<T:Copy> Option<T> { } } -pub impl<T:Copy + Zero> Option<T> { +impl<T:Copy + Zero> Option<T> { /// Returns the contained value or zero (for this type) #[inline(always)] - fn get_or_zero(self) -> T { - match self { Some(x) => x, None => Zero::zero() } + pub fn get_or_zero(self) -> T { + match self { + Some(x) => x, + None => Zero::zero() + } } } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 9eb7b54f009..a551b9bf3c0 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -308,8 +308,8 @@ mod stat { } -pub impl Path { - fn stat(&self) -> Option<libc::stat> { +impl Path { + pub fn stat(&self) -> Option<libc::stat> { unsafe { do str::as_c_str(self.to_str()) |buf| { let mut st = stat::arch::default_stat(); @@ -322,7 +322,7 @@ pub impl Path { } #[cfg(unix)] - fn lstat(&self) -> Option<libc::stat> { + pub fn lstat(&self) -> Option<libc::stat> { unsafe { do str::as_c_str(self.to_str()) |buf| { let mut st = stat::arch::default_stat(); @@ -334,21 +334,21 @@ pub impl Path { } } - fn exists(&self) -> bool { + pub fn exists(&self) -> bool { match self.stat() { None => false, Some(_) => true, } } - fn get_size(&self) -> Option<i64> { + pub fn get_size(&self) -> Option<i64> { match self.stat() { None => None, Some(ref st) => Some(st.st_size as i64), } } - fn get_mode(&self) -> Option<uint> { + pub fn get_mode(&self) -> Option<uint> { match self.stat() { None => None, Some(ref st) => Some(st.st_mode as uint), @@ -359,8 +359,8 @@ pub impl Path { #[cfg(target_os = "freebsd")] #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] -pub impl Path { - fn get_atime(&self) -> Option<(i64, int)> { +impl Path { + pub fn get_atime(&self) -> Option<(i64, int)> { match self.stat() { None => None, Some(ref st) => { @@ -370,7 +370,7 @@ pub impl Path { } } - fn get_mtime(&self) -> Option<(i64, int)> { + pub fn get_mtime(&self) -> Option<(i64, int)> { match self.stat() { None => None, Some(ref st) => { @@ -380,7 +380,7 @@ pub impl Path { } } - fn get_ctime(&self) -> Option<(i64, int)> { + pub fn get_ctime(&self) -> Option<(i64, int)> { match self.stat() { None => None, Some(ref st) => { @@ -393,8 +393,8 @@ pub impl Path { #[cfg(target_os = "freebsd")] #[cfg(target_os = "macos")] -pub impl Path { - fn get_birthtime(&self) -> Option<(i64, int)> { +impl Path { + pub fn get_birthtime(&self) -> Option<(i64, int)> { match self.stat() { None => None, Some(ref st) => { @@ -406,8 +406,8 @@ pub impl Path { } #[cfg(target_os = "win32")] -pub impl Path { - fn get_atime(&self) -> Option<(i64, int)> { +impl Path { + pub fn get_atime(&self) -> Option<(i64, int)> { match self.stat() { None => None, Some(ref st) => { @@ -416,7 +416,7 @@ pub impl Path { } } - fn get_mtime(&self) -> Option<(i64, int)> { + pub fn get_mtime(&self) -> Option<(i64, int)> { match self.stat() { None => None, Some(ref st) => { @@ -425,7 +425,7 @@ pub impl Path { } } - fn get_ctime(&self) -> Option<(i64, int)> { + pub fn get_ctime(&self) -> Option<(i64, int)> { match self.stat() { None => None, Some(ref st) => { diff --git a/src/libstd/pipes.rs b/src/libstd/pipes.rs index 5fbf97dccc8..9607d395151 100644 --- a/src/libstd/pipes.rs +++ b/src/libstd/pipes.rs @@ -152,16 +152,16 @@ pub fn PacketHeader() -> PacketHeader { } } -pub impl PacketHeader { +impl PacketHeader { // Returns the old state. - unsafe fn mark_blocked(&mut self, this: *rust_task) -> State { + pub unsafe fn mark_blocked(&mut 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(&mut self) { + pub unsafe fn unblock(&mut self) { let old_task = swap_task(&mut self.blocked_task, ptr::null()); if !old_task.is_null() { rustrt::rust_task_deref(old_task) @@ -176,12 +176,12 @@ pub impl PacketHeader { // unsafe because this can do weird things to the space/time // continuum. It ends making multiple unique pointers to the same // thing. You'll probably want to forget them when you're done. - unsafe fn buf_header(&mut self) -> ~BufferHeader { + pub unsafe fn buf_header(&mut self) -> ~BufferHeader { assert!(self.buffer.is_not_null()); transmute_copy(&self.buffer) } - fn set_buffer<T:Owned>(&mut self, b: ~Buffer<T>) { + pub fn set_buffer<T:Owned>(&mut self, b: ~Buffer<T>) { unsafe { self.buffer = transmute_copy(&b); } @@ -694,12 +694,12 @@ pub fn SendPacketBuffered<T,Tbuffer>(p: *mut Packet<T>) } } -pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> { - fn unwrap(&mut self) -> *mut Packet<T> { +impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> { + pub fn unwrap(&mut self) -> *mut Packet<T> { replace(&mut self.p, None).unwrap() } - fn header(&mut self) -> *mut PacketHeader { + pub fn header(&mut self) -> *mut PacketHeader { match self.p { Some(packet) => unsafe { let packet = &mut *packet; @@ -710,7 +710,7 @@ pub impl<T,Tbuffer> SendPacketBuffered<T,Tbuffer> { } } - fn reuse_buffer(&mut self) -> BufferResource<Tbuffer> { + pub fn reuse_buffer(&mut self) -> BufferResource<Tbuffer> { //error!("send reuse_buffer"); replace(&mut self.buffer, None).unwrap() } @@ -742,12 +742,12 @@ impl<T:Owned,Tbuffer:Owned> Drop for RecvPacketBuffered<T,Tbuffer> { } } -pub impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> { - fn unwrap(&mut self) -> *mut Packet<T> { +impl<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> { + pub fn unwrap(&mut self) -> *mut Packet<T> { replace(&mut self.p, None).unwrap() } - fn reuse_buffer(&mut self) -> BufferResource<Tbuffer> { + pub fn reuse_buffer(&mut self) -> BufferResource<Tbuffer> { replace(&mut self.buffer, None).unwrap() } } diff --git a/src/libstd/rand.rs b/src/libstd/rand.rs index 07a5acbdde5..40d1744f0fb 100644 --- a/src/libstd/rand.rs +++ b/src/libstd/rand.rs @@ -612,9 +612,9 @@ pub struct IsaacRng { priv c: u32 } -pub impl IsaacRng { +impl IsaacRng { /// Create an ISAAC random number generator with a random seed. - fn new() -> IsaacRng { + pub fn new() -> IsaacRng { IsaacRng::new_seeded(seed()) } @@ -623,7 +623,7 @@ pub impl IsaacRng { /// will be silently ignored. A generator constructed with a given seed /// will generate the same sequence of values as all other generators /// constructed with the same seed. - fn new_seeded(seed: &[u8]) -> IsaacRng { + pub fn new_seeded(seed: &[u8]) -> IsaacRng { let mut rng = IsaacRng { cnt: 0, rsl: [0, .. RAND_SIZE], @@ -643,7 +643,7 @@ pub impl IsaacRng { /// Create an ISAAC random number generator using the default /// fixed seed. - fn new_unseeded() -> IsaacRng { + pub fn new_unseeded() -> IsaacRng { let mut rng = IsaacRng { cnt: 0, rsl: [0, .. RAND_SIZE], @@ -657,7 +657,7 @@ pub impl IsaacRng { /// Initialises `self`. If `use_rsl` is true, then use the current value /// of `rsl` as a seed, otherwise construct one algorithmically (not /// randomly). - priv fn init(&mut self, use_rsl: bool) { + fn init(&mut self, use_rsl: bool) { macro_rules! init_mut_many ( ($( $var:ident ),* = $val:expr ) => { let mut $( $var = $val ),*; @@ -715,7 +715,7 @@ pub impl IsaacRng { /// Refills the output buffer (`self.rsl`) #[inline] - priv fn isaac(&mut self) { + fn isaac(&mut self) { self.c += 1; // abbreviations let mut a = self.a, b = self.b + self.c; @@ -795,9 +795,9 @@ impl Rng for XorShiftRng { } } -pub impl XorShiftRng { +impl XorShiftRng { /// Create an xor shift random number generator with a default seed. - fn new() -> XorShiftRng { + pub fn new() -> XorShiftRng { // constants taken from http://en.wikipedia.org/wiki/Xorshift XorShiftRng::new_seeded(123456789u32, 362436069u32, @@ -807,10 +807,10 @@ pub impl XorShiftRng { /** * Create a random number generator using the specified seed. A generator - * constructed with a given seed will generate the same sequence of values as - * all other generators constructed with the same seed. + * constructed with a given seed will generate the same sequence of values + * as all other generators constructed with the same seed. */ - fn new_seeded(x: u32, y: u32, z: u32, w: u32) -> XorShiftRng { + pub fn new_seeded(x: u32, y: u32, z: u32, w: u32) -> XorShiftRng { XorShiftRng { x: x, y: y, diff --git a/src/libstd/reflect.rs b/src/libstd/reflect.rs index cadfa71e7fa..1eb3d3a0daa 100644 --- a/src/libstd/reflect.rs +++ b/src/libstd/reflect.rs @@ -48,28 +48,28 @@ pub fn MovePtrAdaptor<V:TyVisitor + MovePtr>(v: V) -> MovePtrAdaptor<V> { MovePtrAdaptor { inner: v } } -pub impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> { +impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> { #[inline(always)] - fn bump(&self, sz: uint) { - do self.inner.move_ptr() |p| { + pub fn bump(&self, sz: uint) { + do self.inner.move_ptr() |p| { ((p as uint) + sz) as *c_void - }; + }; } #[inline(always)] - fn align(&self, a: uint) { - do self.inner.move_ptr() |p| { + pub 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>(&self) { + pub fn align_to<T>(&self) { self.align(sys::min_align_of::<T>()); } #[inline(always)] - fn bump_past<T>(&self) { + pub fn bump_past<T>(&self) { self.bump(sys::size_of::<T>()); } } diff --git a/src/libstd/repr.rs b/src/libstd/repr.rs index c50823f471e..14bec48782f 100644 --- a/src/libstd/repr.rs +++ b/src/libstd/repr.rs @@ -174,12 +174,11 @@ impl MovePtr for ReprVisitor { } } -pub impl ReprVisitor { - +impl ReprVisitor { // Various helpers for the TyVisitor impl #[inline(always)] - fn get<T>(&self, f: &fn(&T)) -> bool { + pub fn get<T>(&self, f: &fn(&T)) -> bool { unsafe { f(transmute::<*c_void,&T>(*self.ptr)); } @@ -187,12 +186,12 @@ pub impl ReprVisitor { } #[inline(always)] - fn visit_inner(&self, inner: *TyDesc) -> bool { + pub fn visit_inner(&self, inner: *TyDesc) -> bool { self.visit_ptr_inner(*self.ptr, inner) } #[inline(always)] - fn visit_ptr_inner(&self, ptr: *c_void, inner: *TyDesc) -> bool { + pub fn visit_ptr_inner(&self, ptr: *c_void, inner: *TyDesc) -> bool { unsafe { let u = ReprVisitor(ptr, self.writer); let v = reflect::MovePtrAdaptor(u); @@ -202,13 +201,13 @@ pub impl ReprVisitor { } #[inline(always)] - fn write<T:Repr>(&self) -> bool { + pub fn write<T:Repr>(&self) -> bool { do self.get |v:&T| { v.write_repr(self.writer); } } - fn write_escaped_slice(&self, slice: &str) { + pub fn write_escaped_slice(&self, slice: &str) { self.writer.write_char('"'); for slice.each_char |ch| { self.writer.write_escaped_char(ch); @@ -216,7 +215,7 @@ pub impl ReprVisitor { self.writer.write_char('"'); } - fn write_mut_qualifier(&self, mtbl: uint) { + pub fn write_mut_qualifier(&self, mtbl: uint) { if mtbl == 0 { self.writer.write_str("mut "); } else if mtbl == 1 { @@ -227,8 +226,12 @@ pub impl ReprVisitor { } } - fn write_vec_range(&self, mtbl: uint, ptr: *u8, len: uint, - inner: *TyDesc) -> bool { + pub fn write_vec_range(&self, + mtbl: uint, + ptr: *u8, + len: uint, + inner: *TyDesc) + -> bool { let mut p = ptr; let end = ptr::offset(p, len); let (sz, al) = unsafe { ((*inner).size, (*inner).align) }; @@ -248,13 +251,14 @@ pub impl ReprVisitor { true } - fn write_unboxed_vec_repr(&self, mtbl: uint, v: &UnboxedVecRepr, - inner: *TyDesc) -> bool { + pub 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) } - - } impl TyVisitor for ReprVisitor { diff --git a/src/libstd/result.rs b/src/libstd/result.rs index 5b40b09e98e..8f7a0015bcf 100644 --- a/src/libstd/result.rs +++ b/src/libstd/result.rs @@ -10,7 +10,7 @@ //! A type representing either success or failure -// NB: transitionary, de-mode-ing. +#[allow(missing_doc)]; use cmp::Eq; use either; @@ -227,55 +227,55 @@ pub fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: &fn(&E) -> F) } } -pub impl<T, E> Result<T, E> { +impl<T, E> Result<T, E> { #[inline(always)] - fn get_ref<'a>(&'a self) -> &'a T { get_ref(self) } + pub fn get_ref<'a>(&'a self) -> &'a T { get_ref(self) } #[inline(always)] - fn is_ok(&self) -> bool { is_ok(self) } + pub fn is_ok(&self) -> bool { is_ok(self) } #[inline(always)] - fn is_err(&self) -> bool { is_err(self) } + pub fn is_err(&self) -> bool { is_err(self) } #[inline(always)] - fn iter(&self, f: &fn(&T)) { iter(self, f) } + pub fn iter(&self, f: &fn(&T)) { iter(self, f) } #[inline(always)] - fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) } + pub fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) } #[inline(always)] - fn unwrap(self) -> T { unwrap(self) } + pub fn unwrap(self) -> T { unwrap(self) } #[inline(always)] - fn unwrap_err(self) -> E { unwrap_err(self) } + pub fn unwrap_err(self) -> E { unwrap_err(self) } #[inline(always)] - fn chain<U>(self, op: &fn(T) -> Result<U,E>) -> Result<U,E> { + pub fn chain<U>(self, op: &fn(T) -> Result<U,E>) -> Result<U,E> { chain(self, op) } #[inline(always)] - fn chain_err<F>(self, op: &fn(E) -> Result<T,F>) -> Result<T,F> { + pub fn chain_err<F>(self, op: &fn(E) -> Result<T,F>) -> Result<T,F> { chain_err(self, op) } } -pub impl<T:Copy,E> Result<T, E> { +impl<T:Copy,E> Result<T, E> { #[inline(always)] - fn get(&self) -> T { get(self) } + pub fn get(&self) -> T { get(self) } #[inline(always)] - fn map_err<F:Copy>(&self, op: &fn(&E) -> F) -> Result<T,F> { + pub fn map_err<F:Copy>(&self, op: &fn(&E) -> F) -> Result<T,F> { map_err(self, op) } } -pub impl<T, E: Copy> Result<T, E> { +impl<T, E: Copy> Result<T, E> { #[inline(always)] - fn get_err(&self) -> E { get_err(self) } + pub fn get_err(&self) -> E { get_err(self) } #[inline(always)] - fn map<U:Copy>(&self, op: &fn(&T) -> U) -> Result<U,E> { + pub fn map<U:Copy>(&self, op: &fn(&T) -> U) -> Result<U,E> { map(self, op) } } diff --git a/src/libstd/rt/context.rs b/src/libstd/rt/context.rs index 0d011ce42ba..d5ca8473cee 100644 --- a/src/libstd/rt/context.rs +++ b/src/libstd/rt/context.rs @@ -27,8 +27,8 @@ pub struct Context { regs: ~Registers } -pub impl Context { - fn empty() -> Context { +impl Context { + pub fn empty() -> Context { Context { start: None, regs: new_regs() @@ -36,7 +36,7 @@ pub impl Context { } /// Create a new context that will resume execution by running ~fn() - fn new(start: ~fn(), stack: &mut StackSegment) -> Context { + pub fn new(start: ~fn(), stack: &mut StackSegment) -> Context { // XXX: Putting main into a ~ so it's a thin pointer and can // be passed to the spawn function. Another unfortunate // allocation @@ -71,7 +71,7 @@ pub impl Context { saving the registers values of the executing thread to a Context then loading the registers from a previously saved Context. */ - fn swap(out_context: &mut Context, in_context: &Context) { + pub fn swap(out_context: &mut Context, in_context: &Context) { let out_regs: &mut Registers = match out_context { &Context { regs: ~ref mut r, _ } => r }; diff --git a/src/libstd/rt/sched.rs b/src/libstd/rt/sched.rs index 2d9cdaddc84..064eb63afc6 100644 --- a/src/libstd/rt/sched.rs +++ b/src/libstd/rt/sched.rs @@ -57,11 +57,10 @@ enum CleanupJob { GiveTask(~Coroutine, UnsafeTaskReceiver) } -pub impl Scheduler { +impl Scheduler { + pub fn in_task_context(&self) -> bool { self.current_task.is_some() } - fn in_task_context(&self) -> bool { self.current_task.is_some() } - - fn new(event_loop: ~EventLoopObject) -> Scheduler { + pub fn new(event_loop: ~EventLoopObject) -> Scheduler { // Lazily initialize the runtime TLS key local_ptr::init_tls_key(); @@ -80,7 +79,7 @@ pub impl Scheduler { // the scheduler itself doesn't have to call event_loop.run. // That will be important for embedding the runtime into external // event loops. - fn run(~self) -> ~Scheduler { + pub fn run(~self) -> ~Scheduler { assert!(!self.in_task_context()); let mut self_sched = self; @@ -107,7 +106,7 @@ pub impl Scheduler { /// Pushes the task onto the work stealing queue and tells the event loop /// to run it later. Always use this instead of pushing to the work queue /// directly. - fn enqueue_task(&mut self, task: ~Coroutine) { + pub fn enqueue_task(&mut self, task: ~Coroutine) { self.work_queue.push(task); self.event_loop.callback(resume_task_from_queue); @@ -119,7 +118,7 @@ pub impl Scheduler { // * Scheduler-context operations - fn resume_task_from_queue(~self) { + pub fn resume_task_from_queue(~self) { assert!(!self.in_task_context()); rtdebug!("looking in work queue for task to schedule"); @@ -141,7 +140,7 @@ pub impl Scheduler { /// Called by a running task to end execution, after which it will /// be recycled by the scheduler for reuse in a new task. - fn terminate_current_task(~self) { + pub fn terminate_current_task(~self) { assert!(self.in_task_context()); rtdebug!("ending running task"); @@ -156,7 +155,7 @@ pub impl Scheduler { abort!("control reached end of task"); } - fn schedule_new_task(~self, task: ~Coroutine) { + pub fn schedule_new_task(~self, task: ~Coroutine) { assert!(self.in_task_context()); do self.switch_running_tasks_and_then(task) |last_task| { @@ -167,7 +166,7 @@ pub impl Scheduler { } } - fn schedule_task(~self, task: ~Coroutine) { + pub fn schedule_task(~self, task: ~Coroutine) { assert!(self.in_task_context()); do self.switch_running_tasks_and_then(task) |last_task| { @@ -180,7 +179,7 @@ pub impl Scheduler { // Core scheduling ops - fn resume_task_immediately(~self, task: ~Coroutine) { + pub fn resume_task_immediately(~self, task: ~Coroutine) { let mut this = self; assert!(!this.in_task_context()); @@ -218,7 +217,7 @@ pub impl Scheduler { /// The closure here is a *stack* closure that lives in the /// running task. It gets transmuted to the scheduler's lifetime /// and called while the task is blocked. - fn deschedule_running_task_and_then(~self, f: &fn(~Coroutine)) { + pub fn deschedule_running_task_and_then(~self, f: &fn(~Coroutine)) { let mut this = self; assert!(this.in_task_context()); @@ -248,7 +247,9 @@ pub impl Scheduler { /// Switch directly to another task, without going through the scheduler. /// You would want to think hard about doing this, e.g. if there are /// pending I/O events it would be a bad idea. - fn switch_running_tasks_and_then(~self, next_task: ~Coroutine, f: &fn(~Coroutine)) { + pub fn switch_running_tasks_and_then(~self, + next_task: ~Coroutine, + f: &fn(~Coroutine)) { let mut this = self; assert!(this.in_task_context()); @@ -279,12 +280,12 @@ pub impl Scheduler { // * Other stuff - fn enqueue_cleanup_job(&mut self, job: CleanupJob) { + pub fn enqueue_cleanup_job(&mut self, job: CleanupJob) { assert!(self.cleanup_job.is_none()); self.cleanup_job = Some(job); } - fn run_cleanup_job(&mut self) { + pub fn run_cleanup_job(&mut self) { rtdebug!("running cleanup job"); assert!(self.cleanup_job.is_some()); @@ -305,9 +306,9 @@ pub impl Scheduler { /// callers should first arrange for that task to be located in the /// Scheduler's current_task slot and set up the /// post-context-switch cleanup job. - fn get_contexts<'a>(&'a mut self) -> (&'a mut Context, - Option<&'a mut Context>, - Option<&'a mut Context>) { + pub fn get_contexts<'a>(&'a mut self) -> (&'a mut Context, + Option<&'a mut Context>, + Option<&'a mut Context>) { let last_task = match self.cleanup_job { Some(GiveTask(~ref task, _)) => { Some(task) @@ -349,14 +350,14 @@ pub struct Coroutine { task: ~Task } -pub impl Coroutine { - fn new(stack_pool: &mut StackPool, start: ~fn()) -> Coroutine { +impl Coroutine { + pub fn new(stack_pool: &mut StackPool, start: ~fn()) -> Coroutine { Coroutine::with_task(stack_pool, ~Task::new(), start) } - fn with_task(stack_pool: &mut StackPool, - task: ~Task, - start: ~fn()) -> Coroutine { + pub fn with_task(stack_pool: &mut StackPool, + task: ~Task, + start: ~fn()) -> Coroutine { let start = Coroutine::build_start_wrapper(start); let mut stack = stack_pool.take_segment(MIN_STACK_SIZE); // NB: Context holds a pointer to that ~fn @@ -368,7 +369,7 @@ pub impl Coroutine { }; } - priv fn build_start_wrapper(start: ~fn()) -> ~fn() { + fn build_start_wrapper(start: ~fn()) -> ~fn() { // XXX: The old code didn't have this extra allocation let wrapper: ~fn() = || { // This is the first code to execute after the initial @@ -391,7 +392,7 @@ pub impl Coroutine { } /// Destroy the task and try to reuse its components - fn recycle(~self, stack_pool: &mut StackPool) { + pub fn recycle(~self, stack_pool: &mut StackPool) { match self { ~Coroutine {current_stack_segment, _} => { stack_pool.give_segment(current_stack_segment); diff --git a/src/libstd/rt/stack.rs b/src/libstd/rt/stack.rs index ec56e65931c..fa4b8f30f4e 100644 --- a/src/libstd/rt/stack.rs +++ b/src/libstd/rt/stack.rs @@ -19,8 +19,8 @@ pub struct StackSegment { valgrind_id: c_uint } -pub impl StackSegment { - fn new(size: uint) -> StackSegment { +impl StackSegment { + pub fn new(size: uint) -> StackSegment { unsafe { // Crate a block of uninitialized values let mut stack = vec::with_capacity(size); @@ -38,12 +38,12 @@ pub impl StackSegment { } /// Point to the low end of the allocated stack - fn start(&self) -> *uint { - vec::raw::to_ptr(self.buf) as *uint + pub fn start(&self) -> *uint { + vec::raw::to_ptr(self.buf) as *uint } /// Point one word beyond the high end of the allocated stack - fn end(&self) -> *uint { + pub fn end(&self) -> *uint { vec::raw::to_ptr(self.buf).offset(self.buf.len()) as *uint } } diff --git a/src/libstd/rt/thread.rs b/src/libstd/rt/thread.rs index 0f1ae09bd94..bc290191310 100644 --- a/src/libstd/rt/thread.rs +++ b/src/libstd/rt/thread.rs @@ -19,8 +19,8 @@ pub struct Thread { raw_thread: *raw_thread } -pub impl Thread { - fn start(main: ~fn()) -> Thread { +impl Thread { + pub fn start(main: ~fn()) -> Thread { fn substart(main: &~fn()) -> *raw_thread { unsafe { rust_raw_thread_start(main) } } diff --git a/src/libstd/rt/uv/idle.rs b/src/libstd/rt/uv/idle.rs index 2cf0b5c4872..e1def9ffd50 100644 --- a/src/libstd/rt/uv/idle.rs +++ b/src/libstd/rt/uv/idle.rs @@ -17,8 +17,8 @@ use rt::uv::status_to_maybe_uv_error; pub struct IdleWatcher(*uvll::uv_idle_t); impl Watcher for IdleWatcher { } -pub impl IdleWatcher { - fn new(loop_: &mut Loop) -> IdleWatcher { +impl IdleWatcher { + pub fn new(loop_: &mut Loop) -> IdleWatcher { unsafe { let handle = uvll::idle_new(); assert!(handle.is_not_null()); @@ -29,7 +29,7 @@ pub impl IdleWatcher { } } - fn start(&mut self, cb: IdleCallback) { + pub fn start(&mut self, cb: IdleCallback) { { let data = self.get_watcher_data(); data.idle_cb = Some(cb); @@ -48,16 +48,17 @@ pub impl IdleWatcher { } } - fn stop(&mut self) { - // NB: Not resetting the Rust idle_cb to None here because `stop` is likely - // called from *within* the idle callback, causing a use after free + pub fn stop(&mut self) { + // NB: Not resetting the Rust idle_cb to None here because `stop` is + // likely called from *within* the idle callback, causing a use after + // free unsafe { assert!(0 == uvll::idle_stop(self.native_handle())); } } - fn close(self, cb: NullCallback) { + pub fn close(self, cb: NullCallback) { { let mut this = self; let data = this.get_watcher_data(); diff --git a/src/libstd/rt/uv/mod.rs b/src/libstd/rt/uv/mod.rs index 2bd657fd864..bc968fc3d60 100644 --- a/src/libstd/rt/uv/mod.rs +++ b/src/libstd/rt/uv/mod.rs @@ -92,18 +92,18 @@ pub trait NativeHandle<T> { pub fn native_handle(&self) -> T; } -pub impl Loop { - fn new() -> Loop { +impl Loop { + pub fn new() -> Loop { let handle = unsafe { uvll::loop_new() }; assert!(handle.is_not_null()); NativeHandle::from_native_handle(handle) } - fn run(&mut self) { + pub fn run(&mut self) { unsafe { uvll::run(self.native_handle()) }; } - fn close(&mut self) { + pub fn close(&mut self) { unsafe { uvll::loop_delete(self.native_handle()) }; } } @@ -193,9 +193,8 @@ impl<H, W: Watcher + NativeHandle<*H>> WatcherInterop for W { pub struct UvError(uvll::uv_err_t); -pub impl UvError { - - fn name(&self) -> ~str { +impl UvError { + pub fn name(&self) -> ~str { unsafe { let inner = match self { &UvError(ref a) => a }; let name_str = uvll::err_name(inner); @@ -204,7 +203,7 @@ pub impl UvError { } } - fn desc(&self) -> ~str { + pub fn desc(&self) -> ~str { unsafe { let inner = match self { &UvError(ref a) => a }; let desc_str = uvll::strerror(inner); @@ -213,7 +212,7 @@ pub impl UvError { } } - fn is_eof(&self) -> bool { + pub fn is_eof(&self) -> bool { self.code == uvll::EOF } } diff --git a/src/libstd/rt/uv/net.rs b/src/libstd/rt/uv/net.rs index 68b871e6b31..563d7fd1e81 100644 --- a/src/libstd/rt/uv/net.rs +++ b/src/libstd/rt/uv/net.rs @@ -43,9 +43,8 @@ fn ip4_as_uv_ip4<T>(addr: IpAddr, f: &fn(*sockaddr_in) -> T) -> T { pub struct StreamWatcher(*uvll::uv_stream_t); impl Watcher for StreamWatcher { } -pub impl StreamWatcher { - - fn read_start(&mut self, alloc: AllocCallback, cb: ReadCallback) { +impl StreamWatcher { + pub fn read_start(&mut self, alloc: AllocCallback, cb: ReadCallback) { { let data = self.get_watcher_data(); data.alloc_cb = Some(alloc); @@ -73,7 +72,7 @@ pub impl StreamWatcher { } } - fn read_stop(&mut self) { + pub fn read_stop(&mut self) { // It would be nice to drop the alloc and read callbacks here, // but read_stop may be called from inside one of them and we // would end up freeing the in-use environment @@ -81,7 +80,7 @@ pub impl StreamWatcher { unsafe { uvll::read_stop(handle); } } - fn write(&mut self, buf: Buf, cb: ConnectionCallback) { + pub fn write(&mut self, buf: Buf, cb: ConnectionCallback) { { let data = self.get_watcher_data(); assert!(data.write_cb.is_none()); @@ -110,7 +109,7 @@ pub impl StreamWatcher { } } - fn accept(&mut self, stream: StreamWatcher) { + pub fn accept(&mut self, stream: StreamWatcher) { let self_handle = self.native_handle() as *c_void; let stream_handle = stream.native_handle() as *c_void; unsafe { @@ -118,7 +117,7 @@ pub impl StreamWatcher { } } - fn close(self, cb: NullCallback) { + pub fn close(self, cb: NullCallback) { { let mut this = self; let data = this.get_watcher_data(); @@ -153,8 +152,8 @@ impl NativeHandle<*uvll::uv_stream_t> for StreamWatcher { pub struct TcpWatcher(*uvll::uv_tcp_t); impl Watcher for TcpWatcher { } -pub impl TcpWatcher { - fn new(loop_: &mut Loop) -> TcpWatcher { +impl TcpWatcher { + pub fn new(loop_: &mut Loop) -> TcpWatcher { unsafe { let handle = malloc_handle(UV_TCP); assert!(handle.is_not_null()); @@ -165,7 +164,7 @@ pub impl TcpWatcher { } } - fn bind(&mut self, address: IpAddr) -> Result<(), UvError> { + pub fn bind(&mut self, address: IpAddr) -> Result<(), UvError> { match address { Ipv4(*) => { do ip4_as_uv_ip4(address) |addr| { @@ -183,7 +182,7 @@ pub impl TcpWatcher { } } - fn connect(&mut self, address: IpAddr, cb: ConnectionCallback) { + pub fn connect(&mut self, address: IpAddr, cb: ConnectionCallback) { unsafe { assert!(self.get_watcher_data().connect_cb.is_none()); self.get_watcher_data().connect_cb = Some(cb); @@ -216,7 +215,7 @@ pub impl TcpWatcher { } } - fn listen(&mut self, cb: ConnectionCallback) { + pub fn listen(&mut self, cb: ConnectionCallback) { { let data = self.get_watcher_data(); assert!(data.connect_cb.is_none()); @@ -240,7 +239,7 @@ pub impl TcpWatcher { } } - fn as_stream(&self) -> StreamWatcher { + pub fn as_stream(&self) -> StreamWatcher { NativeHandle::from_native_handle(self.native_handle() as *uvll::uv_stream_t) } } @@ -295,9 +294,8 @@ pub struct WriteRequest(*uvll::uv_write_t); impl Request for WriteRequest { } -pub impl WriteRequest { - - fn new() -> WriteRequest { +impl WriteRequest { + pub fn new() -> WriteRequest { let write_handle = unsafe { malloc_req(UV_WRITE) }; @@ -306,14 +304,14 @@ pub impl WriteRequest { WriteRequest(write_handle) } - fn stream(&self) -> StreamWatcher { + pub fn stream(&self) -> StreamWatcher { unsafe { let stream_handle = uvll::get_stream_handle_from_write_req(self.native_handle()); NativeHandle::from_native_handle(stream_handle) } } - fn delete(self) { + pub fn delete(self) { unsafe { free_req(self.native_handle() as *c_void) } } } diff --git a/src/libstd/rt/uv/uvio.rs b/src/libstd/rt/uv/uvio.rs index cacd67314eb..1d4f65f1517 100644 --- a/src/libstd/rt/uv/uvio.rs +++ b/src/libstd/rt/uv/uvio.rs @@ -33,15 +33,15 @@ pub struct UvEventLoop { uvio: UvIoFactory } -pub impl UvEventLoop { - fn new() -> UvEventLoop { +impl UvEventLoop { + pub fn new() -> UvEventLoop { UvEventLoop { uvio: UvIoFactory(Loop::new()) } } /// A convenience constructor - fn new_scheduler() -> Scheduler { + pub fn new_scheduler() -> Scheduler { Scheduler::new(~UvEventLoop::new()) } } @@ -57,7 +57,6 @@ impl Drop for UvEventLoop { } impl EventLoop for UvEventLoop { - fn run(&mut self) { self.uvio.uv_loop().run(); } @@ -103,8 +102,8 @@ fn test_callback_run_once() { pub struct UvIoFactory(Loop); -pub impl UvIoFactory { - fn uv_loop<'a>(&'a mut self) -> &'a mut Loop { +impl UvIoFactory { + pub fn uv_loop<'a>(&'a mut self) -> &'a mut Loop { match self { &UvIoFactory(ref mut ptr) => ptr } } } diff --git a/src/libstd/rt/uvio.rs b/src/libstd/rt/uvio.rs index 24bffd8d1cd..c7467364b4d 100644 --- a/src/libstd/rt/uvio.rs +++ b/src/libstd/rt/uvio.rs @@ -29,15 +29,15 @@ pub struct UvEventLoop { uvio: UvIoFactory } -pub impl UvEventLoop { - fn new() -> UvEventLoop { +impl UvEventLoop { + pub fn new() -> UvEventLoop { UvEventLoop { uvio: UvIoFactory(Loop::new()) } } /// A convenience constructor - fn new_scheduler() -> Scheduler { + pub fn new_scheduler() -> Scheduler { Scheduler::new(~UvEventLoop::new()) } } @@ -90,8 +90,8 @@ fn test_callback_run_once() { pub struct UvIoFactory(Loop); -pub impl UvIoFactory { - fn uv_loop<'a>(&'a mut self) -> &'a mut Loop { +impl UvIoFactory { + pub fn uv_loop<'a>(&'a mut self) -> &'a mut Loop { match self { &UvIoFactory(ref mut ptr) => ptr } } } diff --git a/src/libstd/rt/work_queue.rs b/src/libstd/rt/work_queue.rs index 4671a45aaea..58d36113f0e 100644 --- a/src/libstd/rt/work_queue.rs +++ b/src/libstd/rt/work_queue.rs @@ -21,21 +21,21 @@ pub struct WorkQueue<T> { priv queue: ~Exclusive<~[T]> } -pub impl<T: Owned> WorkQueue<T> { - fn new() -> WorkQueue<T> { +impl<T: Owned> WorkQueue<T> { + pub fn new() -> WorkQueue<T> { WorkQueue { queue: ~exclusive(~[]) } } - fn push(&mut self, value: T) { + pub fn push(&mut self, value: T) { unsafe { let value = Cell(value); self.queue.with(|q| q.unshift(value.take()) ); } } - fn pop(&mut self) -> Option<T> { + pub fn pop(&mut self) -> Option<T> { unsafe { do self.queue.with |q| { if !q.is_empty() { @@ -47,7 +47,7 @@ pub impl<T: Owned> WorkQueue<T> { } } - fn steal(&mut self) -> Option<T> { + pub fn steal(&mut self) -> Option<T> { unsafe { do self.queue.with |q| { if !q.is_empty() { @@ -59,7 +59,7 @@ pub impl<T: Owned> WorkQueue<T> { } } - fn is_empty(&self) -> bool { + pub fn is_empty(&self) -> bool { unsafe { self.queue.with_imm(|q| q.is_empty() ) } diff --git a/src/libstd/run.rs b/src/libstd/run.rs index de1148e431b..07b521d0197 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -136,8 +136,7 @@ pub struct ProcessOutput { error: ~[u8], } -pub impl Process { - +impl Process { /** * Spawns a new Process. * @@ -148,8 +147,8 @@ pub impl Process { * * options - Options to configure the environment of the process, * the working directory and the standard IO streams. */ - pub fn new(prog: &str, args: &[~str], options: ProcessOptions) -> Process { - + pub fn new(prog: &str, args: &[~str], options: ProcessOptions) + -> Process { let (in_pipe, in_fd) = match options.in_fd { None => { let pipe = os::pipe(); @@ -192,9 +191,9 @@ pub impl Process { } /// Returns the unique id of the process - fn get_id(&self) -> pid_t { self.pid } + pub fn get_id(&self) -> pid_t { self.pid } - priv fn input_fd(&mut self) -> c_int { + fn input_fd(&mut self) -> c_int { match self.input { Some(fd) => fd, None => fail!("This Process's stdin was redirected to an \ @@ -202,7 +201,7 @@ pub impl Process { } } - priv fn output_file(&mut self) -> *libc::FILE { + fn output_file(&mut self) -> *libc::FILE { match self.output { Some(file) => file, None => fail!("This Process's stdout was redirected to an \ @@ -210,7 +209,7 @@ pub impl Process { } } - priv fn error_file(&mut self) -> *libc::FILE { + fn error_file(&mut self) -> *libc::FILE { match self.error { Some(file) => file, None => fail!("This Process's stderr was redirected to an \ @@ -225,7 +224,7 @@ pub impl Process { * * If this method returns true then self.input() will fail. */ - fn input_redirected(&self) -> bool { + pub fn input_redirected(&self) -> bool { self.input.is_none() } @@ -236,7 +235,7 @@ pub impl Process { * * If this method returns true then self.output() will fail. */ - fn output_redirected(&self) -> bool { + pub fn output_redirected(&self) -> bool { self.output.is_none() } @@ -247,7 +246,7 @@ pub impl Process { * * If this method returns true then self.error() will fail. */ - fn error_redirected(&self) -> bool { + pub fn error_redirected(&self) -> bool { self.error.is_none() } @@ -256,7 +255,7 @@ pub impl Process { * * Fails if this Process's stdin was redirected to an existing file descriptor. */ - fn input(&mut self) -> @io::Writer { + pub fn input(&mut self) -> @io::Writer { // FIXME: the Writer can still be used after self is destroyed: #2625 io::fd_writer(self.input_fd(), false) } @@ -266,7 +265,7 @@ pub impl Process { * * Fails if this Process's stdout was redirected to an existing file descriptor. */ - fn output(&mut self) -> @io::Reader { + pub fn output(&mut self) -> @io::Reader { // FIXME: the Reader can still be used after self is destroyed: #2625 io::FILE_reader(self.output_file(), false) } @@ -276,7 +275,7 @@ pub impl Process { * * Fails if this Process's stderr was redirected to an existing file descriptor. */ - fn error(&mut self) -> @io::Reader { + pub fn error(&mut self) -> @io::Reader { // FIXME: the Reader can still be used after self is destroyed: #2625 io::FILE_reader(self.error_file(), false) } @@ -287,7 +286,7 @@ pub impl Process { * If this process is reading its stdin from an existing file descriptor, then this * method does nothing. */ - fn close_input(&mut self) { + pub fn close_input(&mut self) { match self.input { Some(-1) | None => (), Some(fd) => { @@ -299,7 +298,7 @@ pub impl Process { } } - priv fn close_outputs(&mut self) { + fn close_outputs(&mut self) { fclose_and_null(&mut self.output); fclose_and_null(&mut self.error); @@ -322,7 +321,7 @@ pub impl Process { * * If the child has already been finished then the exit code is returned. */ - fn finish(&mut self) -> int { + pub fn finish(&mut self) -> int { for self.exit_code.each |&code| { return code; } @@ -342,8 +341,7 @@ pub impl Process { * This method will fail if the child process's stdout or stderr streams were * redirected to existing file descriptors. */ - fn finish_with_output(&mut self) -> ProcessOutput { - + pub fn finish_with_output(&mut self) -> ProcessOutput { let output_file = self.output_file(); let error_file = self.error_file(); @@ -378,8 +376,7 @@ pub impl Process { error: errs}; } - priv fn destroy_internal(&mut self, force: bool) { - + fn destroy_internal(&mut self, force: bool) { // if the process has finished, and therefore had waitpid called, // and we kill it, then on unix we might ending up killing a // newer process that happens to have the same (re-used) id @@ -417,7 +414,7 @@ pub impl Process { * On Posix OSs SIGTERM will be sent to the process. On Win32 * TerminateProcess(..) will be called. */ - fn destroy(&mut self) { self.destroy_internal(false); } + pub fn destroy(&mut self) { self.destroy_internal(false); } /** * Terminates the process as soon as possible without giving it a @@ -426,7 +423,7 @@ pub impl Process { * On Posix OSs SIGKILL will be sent to the process. On Win32 * TerminateProcess(..) will be called. */ - fn force_destroy(&mut self) { self.destroy_internal(true); } + pub fn force_destroy(&mut self) { self.destroy_internal(true); } } impl Drop for Process { diff --git a/src/libstd/str/ascii.rs b/src/libstd/str/ascii.rs index e48fef01df9..3b31d70f7a1 100644 --- a/src/libstd/str/ascii.rs +++ b/src/libstd/str/ascii.rs @@ -21,22 +21,22 @@ use vec::{CopyableVector, ImmutableVector, OwnedVector}; #[deriving(Clone, Eq)] pub struct Ascii { priv chr: u8 } -pub impl Ascii { +impl Ascii { /// Converts a ascii character into a `u8`. #[inline(always)] - fn to_byte(self) -> u8 { + pub fn to_byte(self) -> u8 { self.chr } /// Converts a ascii character into a `char`. #[inline(always)] - fn to_char(self) -> char { + pub fn to_char(self) -> char { self.chr as char } /// Convert to lowercase. #[inline(always)] - fn to_lower(self) -> Ascii { + pub fn to_lower(self) -> Ascii { if self.chr >= 65 && self.chr <= 90 { Ascii{chr: self.chr | 0x20 } } else { @@ -46,7 +46,7 @@ pub impl Ascii { /// Convert to uppercase. #[inline(always)] - fn to_upper(self) -> Ascii { + pub fn to_upper(self) -> Ascii { if self.chr >= 97 && self.chr <= 122 { Ascii{chr: self.chr & !0x20 } } else { @@ -54,9 +54,9 @@ pub impl Ascii { } } - // Compares two ascii characters of equality, ignoring case. + /// Compares two ascii characters of equality, ignoring case. #[inline(always)] - fn eq_ignore_case(self, other: Ascii) -> bool { + pub fn eq_ignore_case(self, other: Ascii) -> bool { self.to_lower().chr == other.to_lower().chr } } diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index b68abca8605..7c9639bb8f3 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -202,7 +202,7 @@ pub fn task() -> TaskBuilder { } } -priv impl TaskBuilder { +impl TaskBuilder { fn consume(&mut self) -> TaskBuilder { if self.consumed { fail!("Cannot copy a task_builder"); // Fake move mode on self @@ -224,24 +224,24 @@ priv impl TaskBuilder { } } -pub impl TaskBuilder { +impl TaskBuilder { /// Decouple the child task's failure from the parent's. If either fails, /// the other will not be killed. - fn unlinked(&mut self) { + pub fn unlinked(&mut self) { self.opts.linked = false; } /// Unidirectionally link the child task's failure with the parent's. The /// child's failure will not kill the parent, but the parent's will kill /// the child. - fn supervised(&mut self) { + pub fn supervised(&mut self) { self.opts.supervised = true; self.opts.linked = false; } /// Link the child task's and parent task's failures. If either fails, the /// other will be killed. - fn linked(&mut self) { + pub fn linked(&mut self) { self.opts.linked = true; self.opts.supervised = false; } @@ -263,7 +263,7 @@ pub impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - fn future_result(&mut self, blk: &fn(v: Port<TaskResult>)) { + pub fn future_result(&mut self, blk: &fn(v: Port<TaskResult>)) { // 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 @@ -283,7 +283,7 @@ pub impl TaskBuilder { } /// Configure a custom scheduler mode for the task. - fn sched_mode(&mut self, mode: SchedMode) { + pub fn sched_mode(&mut self, mode: SchedMode) { self.opts.sched.mode = mode; } @@ -299,7 +299,7 @@ pub impl TaskBuilder { * generator by applying the task body which results from the * existing body generator to the new body generator. */ - fn add_wrapper(&mut self, wrapper: ~fn(v: ~fn()) -> ~fn()) { + pub fn add_wrapper(&mut self, wrapper: ~fn(v: ~fn()) -> ~fn()) { let prev_gen_body = replace(&mut self.gen_body, None); let prev_gen_body = match prev_gen_body { Some(gen) => gen, @@ -331,7 +331,7 @@ pub impl TaskBuilder { * When spawning into a new scheduler, the number of threads requested * must be greater than zero. */ - fn spawn(&mut self, f: ~fn()) { + pub fn spawn(&mut self, f: ~fn()) { let gen_body = replace(&mut self.gen_body, None); let notify_chan = replace(&mut self.opts.notify_chan, None); let x = self.consume(); @@ -353,7 +353,7 @@ pub impl TaskBuilder { } /// Runs a task, while transfering ownership of one argument to the child. - fn spawn_with<A:Owned>(&mut self, arg: A, f: ~fn(v: A)) { + pub fn spawn_with<A:Owned>(&mut self, arg: A, f: ~fn(v: A)) { let arg = Cell(arg); do self.spawn { f(arg.take()); @@ -373,7 +373,7 @@ pub impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - fn try<T:Owned>(&mut self, f: ~fn() -> T) -> Result<T,()> { + pub fn try<T:Owned>(&mut self, f: ~fn() -> T) -> Result<T,()> { let (po, ch) = stream::<T>(); let mut result = None; diff --git a/src/libstd/trie.rs b/src/libstd/trie.rs index e5b1385974e..aea03b437ca 100644 --- a/src/libstd/trie.rs +++ b/src/libstd/trie.rs @@ -145,28 +145,28 @@ impl<T> Map<uint, T> for TrieMap<T> { } } -pub impl<T> TrieMap<T> { +impl<T> TrieMap<T> { /// Create an empty TrieMap #[inline(always)] - fn new() -> TrieMap<T> { + pub fn new() -> TrieMap<T> { TrieMap{root: TrieNode::new(), length: 0} } /// Visit all key-value pairs in reverse order #[inline(always)] - fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { + pub fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool { self.root.each_reverse(f) } /// Visit all keys in reverse order #[inline(always)] - fn each_key_reverse(&self, f: &fn(&uint) -> bool) -> bool { + pub fn each_key_reverse(&self, f: &fn(&uint) -> bool) -> bool { self.each_reverse(|k, _| f(k)) } /// Visit all values in reverse order #[inline(always)] - fn each_value_reverse(&self, f: &fn(&T) -> bool) -> bool { + pub fn each_value_reverse(&self, f: &fn(&T) -> bool) -> bool { self.each_reverse(|_, v| f(v)) } } @@ -208,28 +208,32 @@ impl Mutable for TrieSet { fn clear(&mut self) { self.map.clear() } } -pub impl TrieSet { +impl TrieSet { /// Create an empty TrieSet #[inline(always)] - fn new() -> TrieSet { + pub fn new() -> TrieSet { TrieSet{map: TrieMap::new()} } /// Return true if the set contains a value #[inline(always)] - fn contains(&self, value: &uint) -> bool { + pub fn contains(&self, value: &uint) -> bool { self.map.contains_key(value) } /// Add a value to the set. Return true if the value was not already /// present in the set. #[inline(always)] - fn insert(&mut self, value: uint) -> bool { self.map.insert(value, ()) } + pub fn insert(&mut self, value: uint) -> bool { + self.map.insert(value, ()) + } /// Remove a value from the set. Return true if the value was /// present in the set. #[inline(always)] - fn remove(&mut self, value: &uint) -> bool { self.map.remove(value) } + pub fn remove(&mut self, value: &uint) -> bool { + self.map.remove(value) + } } struct TrieNode<T> { diff --git a/src/libstd/unstable/extfmt.rs b/src/libstd/unstable/extfmt.rs index 8da378fdc97..07bcf6d953c 100644 --- a/src/libstd/unstable/extfmt.rs +++ b/src/libstd/unstable/extfmt.rs @@ -139,8 +139,8 @@ pub mod ct { next: uint } - pub impl<T> Parsed<T> { - fn new(val: T, next: uint) -> Parsed<T> { + impl<T> Parsed<T> { + pub fn new(val: T, next: uint) -> Parsed<T> { Parsed {val: val, next: next} } } diff --git a/src/libstd/unstable/sync.rs b/src/libstd/unstable/sync.rs index bee317a0b93..f0b178c6670 100644 --- a/src/libstd/unstable/sync.rs +++ b/src/libstd/unstable/sync.rs @@ -117,9 +117,9 @@ fn LittleLock() -> LittleLock { } } -pub impl LittleLock { +impl LittleLock { #[inline(always)] - unsafe fn lock<T>(&self, f: &fn() -> T) -> T { + pub unsafe fn lock<T>(&self, f: &fn() -> T) -> T { do atomically { rust_lock_little_lock(self.l); do (|| { @@ -162,7 +162,7 @@ impl<T:Owned> Clone for Exclusive<T> { } } -pub impl<T:Owned> Exclusive<T> { +impl<T:Owned> Exclusive<T> { // Exactly like std::arc::mutex_arc,access(), but with the little_lock // instead of a proper mutex. Same reason for being unsafe. // @@ -170,7 +170,7 @@ pub impl<T:Owned> Exclusive<T> { // accessing the provided condition variable) are prohibited while inside // the exclusive. Supporting that is a work in progress. #[inline(always)] - unsafe fn with<U>(&self, f: &fn(x: &mut T) -> U) -> U { + pub unsafe fn with<U>(&self, f: &fn(x: &mut T) -> U) -> U { let rec = self.x.get(); do (*rec).lock.lock { if (*rec).failed { @@ -184,7 +184,7 @@ pub impl<T:Owned> Exclusive<T> { } #[inline(always)] - unsafe fn with_imm<U>(&self, f: &fn(x: &T) -> U) -> U { + pub unsafe fn with_imm<U>(&self, f: &fn(x: &T) -> U) -> U { do self.with |x| { f(cast::transmute_immut(x)) } diff --git a/src/libstd/util.rs b/src/libstd/util.rs index 21fbe2836cd..e8e68ddd632 100644 --- a/src/libstd/util.rs +++ b/src/libstd/util.rs @@ -90,9 +90,9 @@ pub fn NonCopyable() -> NonCopyable { NonCopyable { i: () } } /// A type with no inhabitants pub enum Void { } -pub impl Void { +impl Void { /// A utility function for ignoring this uninhabited type - fn uninhabited(self) -> ! { + pub fn uninhabited(self) -> ! { match self { // Nothing to match on } |
