We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If I understand what I am doing, then, if
pub fn mean<I>(it: I) -> f64 where I: Iterator, <I as Iterator>::Item: ToPrimitive,
was changed to something like
fn mean<'a, I, T>(x:I)-> f64 where I: IntoIterator<Item= T>, 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.
The text was updated successfully, but these errors were encountered:
Yes, the API should use IntoIterator. This crate was actually written IntoIterator existed (IIRC), and I just never updated the APIs.
IntoIterator
But you don't need vec![1, 2, 3].iter().collect(). Just &[1, 2, 3].iter() should work. Or at least, &[1, 2, 3].iter().cloned().
vec![1, 2, 3].iter().collect()
&[1, 2, 3].iter()
&[1, 2, 3].iter().cloned()
Sorry, something went wrong.
No branches or pull requests
If I understand what I am doing, then, if
was changed to something like
You could also use mean on vectors. e.g.
as opposed to
without losing any functionality for iterators themselves. But I am just learning Rust, so I might not understand some limitation of this approach.
The text was updated successfully, but these errors were encountered: