From 386a7fca0a9a26a06390da7b5da17e5ecf2835e7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 27 Feb 2021 10:42:21 +0000 Subject: [PATCH] use PosC::try_from_iter[_2] Signed-off-by: Ian Jackson --- src/spec.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) 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() } } -- 2.30.2