From: Ian Jackson Date: Sun, 6 Mar 2022 11:37:25 +0000 (+0000) Subject: zcoord: Make MutateReturn take self parameter X-Git-Tag: otter-1.0.0~160 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ff3189f4f7b7ecf8774e29eec943236fe0fe2179;p=otter.git zcoord: Make MutateReturn take self parameter This avoids a warning about IteratorCore::mr being dead code. --- diff --git a/base/zcoord.rs b/base/zcoord.rs index 2264174c..85dcae17 100644 --- a/base/zcoord.rs +++ b/base/zcoord.rs @@ -303,35 +303,36 @@ pub type RangeIterator = std::iter::Take< IteratorCore >; -pub trait MutateReturn { +pub trait MutateReturn: Copy { fn op U> - (x: &mut T, + (self, + x: &mut T, m: M, o: O) -> U; } -#[derive(Debug)] +#[derive(Debug,Copy,Clone)] pub struct MutateFirst; impl MutateReturn for MutateFirst { fn op U> - (x: &mut T, m: M, o: O) -> U + (self, x: &mut T, m: M, o: O) -> U { m(x); o(x) } } -#[derive(Debug)] +#[derive(Debug,Copy,Clone)] pub struct MutateLast; impl MutateReturn for MutateLast { fn op U> - (x: &mut T, m: M, o: O) -> U + (self, x: &mut T, m: M, o: O) -> U { let u = o(x); m(x); @@ -453,7 +454,7 @@ impl Iterator for IteratorCore { type Item = ZCoord; fn next(&mut self) -> Option { let aso = &self.aso; - Some(MR::op( + Some(self.mr.op( &mut self.current, |current| { current.addsub(aso).unwrap(); }, |current| { current.repack().unwrap() },