-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
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
Support non-consuming operations #3
Comments
This should work: let xs = vec![1, 2, 3];
let avg = mean(xs.iter().cloned());
println!("xs is still mine: {:?}", xs); The trick here is that |
Ok, that optimization should work in the common cases. However, it's still cloning before converting to an f64, rather than converting from a reference to the data. You'll have to suggest to people to |
Yes, if your type doesn't impl More broadly: I don't really have a good vision for this crate. My hope is that something more cohesive takes its place, but I'm not really the right person to lead that charge. I should probably put that in the README. |
I'm calculating both mean and stddev on some data, but I find that I have to clone my data vec to do it. The functions as they are consume an iterator, whose item type must implement
ToPrimitive
. ButToPrimitive
is not defined over&i32
and the like, so I can't use, for example,mean(vec![1,2,3].iter())
. I had to use something likemean(vec![1,2,3].clone().into_iter()
. I had small examples, but I think you want this library to scale, and cloning data to calculate stats won't scale.The text was updated successfully, but these errors were encountered: