From: Ian Jackson Date: Sat, 27 Feb 2021 10:42:21 +0000 (+0000) Subject: use PosC::try_from_iter[_2] X-Git-Tag: otter-0.4.0~329 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=386a7fca0a9a26a06390da7b5da17e5ecf2835e7;p=otter.git use PosC::try_from_iter[_2] Signed-off-by: Ian Jackson --- diff --git a/src/spec.rs b/src/spec.rs index cd85b09d..38908bdd 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -270,14 +270,12 @@ pub mod pos_traits { type Output = Result; #[throws(CoordinateOverflow)] fn sub(self, rhs: PosC) -> PosC { - PosC( + PosC::try_from_iter_2( itertools::zip_eq( self.0.iter().cloned(), rhs .0.iter().cloned(), ).map(|(a,b)| a.checked_sub(b)) - .collect::,_>>()? - .into_inner().unwrap() - ) + )? } } @@ -285,13 +283,11 @@ pub mod pos_traits { type Output = Result; #[throws(CoordinateOverflow)] fn mul(self, rhs: S) -> PosC { - PosC( + PosC::try_from_iter_2( self.0.iter().cloned().map( |a| a.checked_mul(rhs) ) - .collect::,_>>()? - .into_inner().unwrap() - ) + )? } } @@ -308,10 +304,9 @@ pub mod pos_traits { impl PosC { pub fn map U>(self, f: F) -> PosC { - PosC( + PosC::from_iter( self.0.iter().cloned().map(f) - .collect::>().into_inner().unwrap() - ) + ).unwrap() } }