digitalmars.D.bugs - [Issue 23453] New: Generic iota should be a forward range
- d-bugmail puremagic.com (39/39) Nov 03 2022 https://issues.dlang.org/show_bug.cgi?id=23453
https://issues.dlang.org/show_bug.cgi?id=23453 Issue ID: 23453 Summary: Generic iota should be a forward range Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody puremagic.com Reporter: snarwin+bugzilla gmail.com As of Phobos v2.100.2, the generic version of std.range.iota used for non-numeric types is not a forward range, because it does not implement the `save` method: --- import std.range; void main() { auto r1 = iota('a', 'z'); auto r2 = r1.save; // Error } --- However, iota stores all of its state internally, and copies of it can be iterated independently: --- import std.range; void main() { auto r1 = iota('a', 'z'); auto r2 = r1; r1.popFront; assert(r2.front == 'a'); // OK } --- Since it is already effectively a forward range in practice, iota should implement `save` and make this functionality available to generic algorithms. --
Nov 03 2022