From 25c9d03aae9af8ce1ed208795b19917778efef9d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 11 Oct 2020 10:43:58 +0100 Subject: [PATCH] generalise Signed-off-by: Ian Jackson --- zcoord/zcoord.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/zcoord/zcoord.rs b/zcoord/zcoord.rs index aabc2cb7..84b0c06f 100644 --- a/zcoord/zcoord.rs +++ b/zcoord/zcoord.rs @@ -135,7 +135,7 @@ impl From for Overflow { fn from(_: TryFromIntError) -> Overflow { Overflow } } -trait AddSubOffset { +pub trait AddSubOffset { fn init_delta(&self) -> LimbVal; const CARRY_DELTA : LimbVal; const NEW_LIMBS : LimbVal; @@ -233,14 +233,14 @@ impl Mutable { } } -pub type RangeIterator = std::iter::Take; +pub type RangeIterator = std::iter::Take>; -pub struct RangeIteratorCore { +pub struct IteratorCore { current: Mutable, - aso: AddSubRangeDelta, + aso: ASO, } -struct AddSubRangeDelta { +pub struct AddSubRangeDelta { i: usize, step: LimbVal, } @@ -267,7 +267,8 @@ impl Mutable { } #[throws(RangeBackwards)] - fn range_core(a: &Mutable, b: &Mutable, count: u32) -> RangeIteratorCore { + fn range_core(a: &Mutable, b: &Mutable, count: u32) + -> IteratorCore { type ASRD = AddSubRangeDelta; let count = count as RawLimbVal; let mut current = a.clone(); @@ -318,7 +319,7 @@ impl Mutable { current.limbs[i] = init; break 'ok ASRD { i, step: Wrapping(step) }; } }; - RangeIteratorCore { current, aso } + IteratorCore { current, aso } } #[throws(RangeBackwards)] @@ -327,7 +328,7 @@ impl Mutable { } } -impl Iterator for RangeIteratorCore { +impl Iterator for IteratorCore { type Item = ZCoord; #[throws(as Option)] fn next(&mut self) -> ZCoord { @@ -335,7 +336,7 @@ impl Iterator for RangeIteratorCore { self.current.repack().unwrap() } } -impl ExactSizeIterator for RangeIteratorCore { +impl ExactSizeIterator for IteratorCore { fn len(&self) -> usize { return usize::MAX } } -- 2.30.2