core: add unwrap methods to dvec, either, and mutable
This commit is contained in:
parent
82a983de68
commit
2ad41b881c
3 changed files with 14 additions and 0 deletions
|
@ -110,6 +110,9 @@ priv impl<A> DVec<A> {
|
||||||
self.data = move data;
|
self.data = move data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn unwrap(self) -> ~[A] { unwrap(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// In theory, most everything should work with any A, but in practice
|
// In theory, most everything should work with any A, but in practice
|
||||||
|
|
|
@ -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]
|
#[test]
|
||||||
fn test_either_left() {
|
fn test_either_left() {
|
||||||
let val = Left(10);
|
let val = Left(10);
|
||||||
|
|
|
@ -73,6 +73,9 @@ impl<T> Data<T> {
|
||||||
op(unsafe{transmute_immut(&mut self.value)})
|
op(unsafe{transmute_immut(&mut self.value)})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
fn unwrap(self) -> T { unwrap(self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in a new issue