Skip to content

Commit 2ad41b8

Browse files
Erick Tryzelaarerickt
Erick Tryzelaar
authored andcommitted
core: add unwrap methods to dvec, either, and mutable
1 parent 82a983d commit 2ad41b8

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/libcore/dvec.rs

+3
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ priv impl<A> DVec<A> {
110110
self.data = move data;
111111
}
112112
}
113+
114+
#[inline(always)]
115+
fn unwrap(self) -> ~[A] { unwrap(self) }
113116
}
114117

115118
// In theory, most everything should work with any A, but in practice

src/libcore/either.rs

+8
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
142142
}
143143
}
144144

145+
impl<T, U> Either<T, U> {
146+
#[inline(always)]
147+
fn unwrap_left(self) -> T { unwrap_left(self) }
148+
149+
#[inline(always)]
150+
fn unwrap_right(self) -> U { unwrap_right(self) }
151+
}
152+
145153
#[test]
146154
fn test_either_left() {
147155
let val = Left(10);

src/libcore/mutable.rs

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ impl<T> Data<T> {
7373
op(unsafe{transmute_immut(&mut self.value)})
7474
}
7575
}
76+
77+
#[inline(always)]
78+
fn unwrap(self) -> T { unwrap(self) }
7679
}
7780

7881
#[test]

0 commit comments

Comments
 (0)