From: Ian Jackson Date: Sat, 10 Jul 2021 15:07:16 +0000 (+0100) Subject: zcoord: document (and test a bit more) range_upto() X-Git-Tag: otter-0.7.2~163 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=5c6d67fc96d874ba8d760ce401510722d5eb8ff5;p=otter.git zcoord: document (and test a bit more) range_upto() Signed-off-by: Ian Jackson --- diff --git a/base/zcoord.rs b/base/zcoord.rs index a04abb9c..2f3e8690 100644 --- a/base/zcoord.rs +++ b/base/zcoord.rs @@ -427,6 +427,9 @@ impl Mutable { } #[throws(RangeBackwards)] + /// Iterator producing a half-open range `[self, other>` + /// + /// Produces precisely `count` items. pub fn range_upto(&self, other: &Mutable, count: RangeCount) -> RangeIterator { let (current, aso) = Mutable::range_core(self, other, count)?; @@ -919,6 +922,15 @@ mod test { it.nxt("3333333334_0000000020"); it.nxt("3333333334_0000000030"); assert_eq!(it.i.next(), None); + + let x = bf("1000000000").clone_mut(); + let y = bf("2000000000").clone_mut(); + let i = x.range_upto(&y, 3).unwrap(); + let mut it = It { i, last: x.repack().unwrap() }; + it.nxt("1800000000"); + it.nxt("1g00000000"); + it.nxt("1o00000000"); + assert_eq!(it.i.next(), None); } #[test]