`from_iter` implementation may run indefinitely
- Dominant language
- Rust
- Stars
- 4.8k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
Creating a vector or a matrix with the `from_iter` method may run indefinitely. I don't think this is the expected behaviour. I.e.
```rust
#[test]
fn test_nalgebra_finishes() {
use nalgebra::DVector; // 0.32.5
use std::iter;
// Runs indefinitely
let _vector = DVector::from_iterator(70, iter::from_fn(|| Some(1)));
}
```
will never finish. ([Playground](https://play.rust-lang.org/?version=stable&mode=release&edition=2021))
I think it would make sense to either:
1. Limit the iterator automatically and ignore the remaining entries.
2. Panic if the iterator has elements remaining if the capacity has been reached.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.