diff options
| author | Michael Woerister <michaelwoerister@gmail> | 2013-08-07 14:29:29 +0200 |
|---|---|---|
| committer | Michael Woerister <michaelwoerister@gmail> | 2013-08-07 14:30:00 +0200 |
| commit | 2c9922aa491f406d0a17631ef2f0bfc0bbf85346 (patch) | |
| tree | 67a8dd9e22edd3a57bcd5961e031ab6548605bd1 /src/libsyntax/opt_vec.rs | |
| parent | 4da1cfe92369725b2e6bf34acb1fdebdbaff9339 (diff) | |
| download | rust-2c9922aa491f406d0a17631ef2f0bfc0bbf85346.tar.gz rust-2c9922aa491f406d0a17631ef2f0bfc0bbf85346.zip | |
Enable privacy check for enum methods.
Diffstat (limited to 'src/libsyntax/opt_vec.rs')
| -rw-r--r-- | src/libsyntax/opt_vec.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 10603751a06..a6f6b9d48e2 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -36,7 +36,7 @@ pub fn from<T>(t: ~[T]) -> OptVec<T> { } impl<T> OptVec<T> { - fn push(&mut self, t: T) { + pub fn push(&mut self, t: T) { match *self { Vec(ref mut v) => { v.push(t); @@ -50,32 +50,32 @@ impl<T> OptVec<T> { *self = Vec(~[t]); } - fn map<U>(&self, op: &fn(&T) -> U) -> OptVec<U> { + pub fn map<U>(&self, op: &fn(&T) -> U) -> OptVec<U> { match *self { Empty => Empty, Vec(ref v) => Vec(v.map(op)) } } - fn map_consume<U>(self, op: &fn(T) -> U) -> OptVec<U> { + pub fn map_consume<U>(self, op: &fn(T) -> U) -> OptVec<U> { match self { Empty => Empty, Vec(v) => Vec(v.consume_iter().transform(op).collect()) } } - fn get<'a>(&'a self, i: uint) -> &'a T { + pub fn get<'a>(&'a self, i: uint) -> &'a T { match *self { Empty => fail!("Invalid index %u", i), Vec(ref v) => &v[i] } } - fn is_empty(&self) -> bool { + pub fn is_empty(&self) -> bool { self.len() == 0 } - fn len(&self) -> uint { + pub fn len(&self) -> uint { match *self { Empty => 0, Vec(ref v) => v.len() @@ -83,7 +83,7 @@ impl<T> OptVec<T> { } #[inline] - fn iter<'r>(&'r self) -> OptVecIterator<'r, T> { + pub fn iter<'r>(&'r self) -> OptVecIterator<'r, T> { match *self { Empty => OptVecIterator{iter: None}, Vec(ref v) => OptVecIterator{iter: Some(v.iter())} @@ -91,11 +91,11 @@ impl<T> OptVec<T> { } #[inline] - fn map_to_vec<B>(&self, op: &fn(&T) -> B) -> ~[B] { + pub fn map_to_vec<B>(&self, op: &fn(&T) -> B) -> ~[B] { self.iter().transform(op).collect() } - fn mapi_to_vec<B>(&self, op: &fn(uint, &T) -> B) -> ~[B] { + pub fn mapi_to_vec<B>(&self, op: &fn(uint, &T) -> B) -> ~[B] { let mut index = 0; self.map_to_vec(|a| { let i = index; @@ -113,7 +113,7 @@ pub fn take_vec<T>(v: OptVec<T>) -> ~[T] { } impl<T:Clone> OptVec<T> { - fn prepend(&self, t: T) -> OptVec<T> { + pub fn prepend(&self, t: T) -> OptVec<T> { let mut v0 = ~[t]; match *self { Empty => {} @@ -124,7 +124,7 @@ impl<T:Clone> OptVec<T> { } impl<A:Eq> Eq for OptVec<A> { - fn eq(&self, other: &OptVec<A>) -> bool { + pub fn eq(&self, other: &OptVec<A>) -> bool { // Note: cannot use #[deriving(Eq)] here because // (Empty, Vec(~[])) ought to be equal. match (self, other) { @@ -135,7 +135,7 @@ impl<A:Eq> Eq for OptVec<A> { } } - fn ne(&self, other: &OptVec<A>) -> bool { + pub fn ne(&self, other: &OptVec<A>) -> bool { !self.eq(other) } } |
