« first day (3338 days earlier)      last day (413 days later) » 

03:48
\o Mornings :)
Does anyone use CLion? I've recently discovered (rediscovered? Started paying attention to?) that it shows me scary "use of moved value" and such hard red error underlines that the compiler itself doesn't seem to mind. Wondering if there's a config I'm overlooking, having no luck in the inspections.
Relatedly, I've started reading crafting interpreters but doing it in Rust and I'm proud to say I'm steadily discovering ever new ways to write faulty code, very nice journey.
 
8 hours later…
12:14
@Stargateur Hilarious, isn't it? ;)
 
1 hour later…
13:42
@FĂ©lixAdriyelGagnon-Grenier I don't use CLion (sorry), just wanted to note you may want to check out Rust Rover instead. Still JetBrains, dedicated to Rust.
 
3 hours later…
16:56
@MatthieuM. as a dedicated jetbrains fanboy, I am very happy with learning of that tool, thanks! It seems there's still some kinds of warnings (in rust rover) that the compiler doesn't scream about, but they do be looking weird anyway so I may yet just comply with it.
 
4 hours later…
21:20
Hello, guys.

Traditional reading of any csv-file with csv crate looks like:
let mut rdr = csv::ReaderBuilder::new().from_reader(data.as_bytes());

for result in rdr.records() {

   let record = result?;

//do something

}

Ok(())
How I can read this file entirely, not line-by-line?
Somehow with while?
That should be possible to work with records in a desired order
21:58
@manro Not sure what you mean; that code will have read the whole file when the for-loop ends
@kmdreko ah, evidently, problem is in iter
for result in rdr.records() {
        let record = result?;
	loop{

		let query1 = user_input();

        if record.iter().any(|field| field == query1.trim()) {
            value = record[1].parse::<f32>().unwrap();
			println!("{}", limit);
			break;
        }
		else{
           println!("Invalid input.  Please try again");
           continue;
        }
    }
formatting has swum away
I have modified an example from rust cookbook
I want to work with file's rows as much as I want
in an accidental order
*value instead of limit :)
I have changed above-described construction to:
if (record[0].trim() == query1.trim()){
     //do something
}
Same story :-(
Did my first reflection (for -> while) is right?

« first day (3338 days earlier)      last day (413 days later) »