Improve Ops API

This commit is contained in:
Andreas Longva 2020-12-21 15:13:31 +01:00
parent fe8592fde1
commit 061024ab1f
1 changed files with 9 additions and 8 deletions

View File

@ -15,10 +15,7 @@ pub enum Op<T> {
impl<T> Op<T> {
/// TODO
pub fn inner_ref(&self) -> &T {
match self {
Op::NoOp(obj) => &obj,
Op::Transpose(obj) => &obj
}
self.as_ref().unwrap()
}
/// TODO
@ -33,10 +30,7 @@ impl<T> Op<T> {
pub fn convert<U>(self) -> Op<U>
where T: Into<U>
{
match self {
Op::NoOp(obj) => Op::NoOp(obj.into()),
Op::Transpose(obj) => Op::Transpose(obj.into())
}
self.map_same_op(T::into)
}
/// TODO
@ -47,6 +41,13 @@ impl<T> Op<T> {
Op::Transpose(obj) => Op::Transpose(f(obj))
}
}
/// TODO
pub fn unwrap(self) -> T {
match self {
Op::NoOp(obj) | Op::Transpose(obj) => obj,
}
}
}
impl<T> From<T> for Op<T> {