a-range
                                
                                 a-range copied to clipboard
                                
                                    a-range copied to clipboard
                            
                            
                            
                        Add `.iter` method on `Range`
- [ ] for i in a_range::from(1).up_to(5).iter() { let _i: &i32 = i; }compiles
- [ ] Tests added as doc tests on iter()method
The way I understood, you want an IntoIterator implementation for &Range<Idx, Upwards>, so that for &i in &a_range::from(1).up_to(5) {} compiles.
But isn't it unnecessary since Range does not really store any value?
I want to have a way to iterate over a range without it being consumed. Implementing IntoIterator on a reference is one way to do it. And this implementation could call .iter().
But isn't it unnecessary since Range does not really store any value?
I'm not sure I understand. Range has three fields. The index types may be arbitrarily complex, including internal mutability.
Am 21.10.2018 um 20:55 schrieb Ranadeep Biswas [email protected]:
The way I understood, you want an IntoIterator implementation for &Range<Idx, Upwards>, so that for &i in &a_range::from(1).up_to(5) {} compiles.
But isn't it unnecessary since Range does not really store any value?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
I meant unnecessary as in there is nothing to be consumed stored in Range. Even Rust's std::ops::Range does not have .iter() implemented. Can you give one example why you would want that?