core: add unwrap methods to dvec, either, and mutable

This commit is contained in:
Erick Tryzelaar 2012-12-18 18:54:25 -08:00 committed by Erick Tryzelaar
parent 82a983de68
commit 2ad41b881c
3 changed files with 14 additions and 0 deletions

View file

@ -110,6 +110,9 @@ priv impl<A> DVec<A> {
self.data = move data;
}
}
#[inline(always)]
fn unwrap(self) -> ~[A] { unwrap(self) }
}
// In theory, most everything should work with any A, but in practice

View file

@ -142,6 +142,14 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
}
}
impl<T, U> Either<T, U> {
#[inline(always)]
fn unwrap_left(self) -> T { unwrap_left(self) }
#[inline(always)]
fn unwrap_right(self) -> U { unwrap_right(self) }
}
#[test]
fn test_either_left() {
let val = Left(10);

View file

@ -73,6 +73,9 @@ impl<T> Data<T> {
op(unsafe{transmute_immut(&mut self.value)})
}
}
#[inline(always)]
fn unwrap(self) -> T { unwrap(self) }
}
#[test]