These are chat archives for rust-lang/rust
error[E0191]: the value of the associated type `Item` (from the trait `std::iter::Iterator`) must be specified --> src/main.rs:30:72 | 30 | None => std::iter::once(EventReader::new(std::io::stdin())) as Iterator, | ^^^^^^^^ missing associated type `Item` value
Just a performance question in calculations: I try to use a
Vec of 100_000 elements (container based products from postgres db / diesel) in about ~ 10
fns. And as this
Vec is optionally on fn call, it is declared as
&Option<Vec<X>>. The question is: How do I use this
Vec most efficient for different function calls?
Is this the right way?
let vec = X::find_all_based_on_y(y); fn1(&Some(vec)); fn2(&Some(vec)); fn3(&Some(vec)); …
Or is there a more efficient way? The idea was, to not query the products in every fn, as this would get slow.
Some(&vec)the right way to do this, to prevent moving of value?
fn2(&Some(vec));because the vec was moved; I'd probably do a
let vec = Some(X::find_all..);and then
3*size_of::<usize>so as long as you are not cloning the whole 100_000 element vector, it shouldn't really matter
Some(&Vec<_>)which I think is equally good, or better, might be more idiomatic even than