Add copying `IntoIter` implementation
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
Apologies if any terms aren't right, I'm still learning rust.
Currently, if you want to return an iterator consuming a temporary variable, you can't, because `IntoIter` is only implemented for `&T` and `&mut T`.
```rust
// Works, because arrays implement IntoIter returning f32
for x in (|| [0.0f32, 1.0f32].into_iter())() {
print!("{}\n", x);
}
// Does not work, because nalgebra::Vector2 does not implement IntoIter returning f32, so the compiler picks &f32 instead
for x in (|| Vector2::new(0.0f32, 1.0f32).into_iter())() {
print!("{}\n", x);
}
```
https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=e3c5472e96dbe560be70cf3c5e55c6b8
I was wondering if would possible to add the missing to implementation to support this? Is there some potential technical limitation I can't see?
Note that it's currently possible to work around this problem for very simple situations by chaining iterators over copies of each field.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.