BurntSushi / BurntSushi/rust-stats
Is there a reason parameters are Iterators instead of IntoIterator?
- Dominant language
- Rust
- Stars
- 89
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Description
If I understand what I am doing, then, if
```
pub fn mean(it: I) -> f64 where
I: Iterator,
::Item: ToPrimitive,
```
was changed to something like
```
fn mean<'a, I, T>(x:I)-> f64 where
I: IntoIterator,
T: Into<&'a f64>
{
let it = x.into_iter();
...
}
```
You could also use mean on vectors. e.g.
```
mean(&vec![1,2,3])
```
as opposed to
```
mean(vec![1,2,3].iter().collect())
```
without losing any functionality for iterators themselves. But I am just learning Rust, so I might not understand some limitation of this approach.
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names only the mean function signature and example calls; start by locating that API in the repository and reviewing the surrounding iterator constraints. Compare the proposed IntoIterator form with the existing iterator behavior and determine whether the public API change preserves both use cases. Done means reaching and recording a clear compatibility decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100