diff --git a/nalgebra-sparse/src/ops/mod.rs b/nalgebra-sparse/src/ops/mod.rs index 14a18dc1..80fde80d 100644 --- a/nalgebra-sparse/src/ops/mod.rs +++ b/nalgebra-sparse/src/ops/mod.rs @@ -15,10 +15,7 @@ pub enum Op { impl Op { /// 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 Op { pub fn convert(self) -> Op where T: Into { - 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 Op { Op::Transpose(obj) => Op::Transpose(f(obj)) } } + + /// TODO + pub fn unwrap(self) -> T { + match self { + Op::NoOp(obj) | Op::Transpose(obj) => obj, + } + } } impl From for Op {