These are chat archives for rust-lang/rust

31st
May 2017
Roland Tepp
@luolong
May 31 2017 06:10
So, I tried casting:
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
(one of many errors)
Sebastian Blei
@iamsebastian
May 31 2017 06:25

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.

Maybe is Some(&vec) the right way to do this, to prevent moving of value?
Joonas Koivunen
@koivunej
May 31 2017 06:45
@iamsebastian I'd expect that code to fail on fn2(&Some(vec)); because the vec was moved; I'd probably do a let vec = Some(X::find_all..); and then fn1(&vec)
Joonas Koivunen
@koivunej
May 31 2017 06:45
@iamsebastian either way, size_of::<Vec<_>> is about 3*size_of::<usize> so as long as you are not cloning the whole 100_000 element vector, it shouldn't really matter
@iamsebastian on a grander scale, if you end up downloading 100_000 rows from postgres for anything I'd look into stored procedures
Sebastian Blei
@iamsebastian
May 31 2017 06:49
In the past, I've just cloned many structs to strife away from lifetimes and design decisions, and just go straight forward with performance issues. But now, as I've get more familiar with Rust, I try to do it more right. The project is about ~ 14 months going on, and I'm getting more and more knowledge about the lang.
I just picked rust for writing the API. But never touched rust before. For now, it seems, it was a good decision.
Sebastian Blei
@iamsebastian
May 31 2017 06:55
Atm, I query these products about ten times a day. So not that regular.
Vasily Kirichenko
@vasily-kirichenko
May 31 2017 06:56
if there is a profiler for Rust, it's time to launch it I think :)
Sebastian Blei
@iamsebastian
May 31 2017 06:57
Those simple fns I sometimes check via bench.
Joonas Koivunen
@koivunej
May 31 2017 06:57
@iamsebastian forgot to reply, in your play example you use Some(&Vec<_>) which I think is equally good, or better, might be more idiomatic even than &Option<Vec<_>>
Sebastian Blei
@iamsebastian
May 31 2017 06:59
As I started the question parallel on #rust, maybe this seems to be more idiomatic:
http://play.integer32.com/?gist=1ca1d8972ecc38bb70d4c400c7f82789&version=stable
Ty for your time, @koivunej
Joonas Koivunen
@koivunej
May 31 2017 07:00
my suggestion about doing heavy lifting near the data in the database is because of my personal experiences understanding why code works on local test environment (little data, localhost connection) and fails in production (lots of data, nework connection)
Sebastian Blei
@iamsebastian
May 31 2017 07:01
Yeah, I know the problem from the last node.js API I've built with much reduced data but a bunch more live-querying, as it was kinda streaming API.
But the actual project is just: few customers, but much data. But the data is handled on local system - on dev and production.
Just spread via docker containers.
Salar Rahmanian
@softinio
May 31 2017 13:28
whats the go to editor or IDE for rust these days?
Jonas Platte
@jplatte
May 31 2017 13:31
@softinio Visual Studio Code, with the Rust extension
Vasily Kirichenko
@vasily-kirichenko
May 31 2017 18:05
@softinio Intellij
devlinzed
@devlinzed
May 31 2017 20:54
neovim
Michael Eden
@illegalprime
May 31 2017 23:43
Emacs