« first day (3339 days earlier)      last day (363 days later) » 

01:22
posted on December 05, 2023 by Release automation

The 1.74.1 pre-release is ready for testing. The release is scheduled for December 7. Release notes can be found here. You can try it out locally by running: RUSTUP_DIST_SERVER=https://dev-static.rust-lang.org rustup update stable The index is https://dev-static.rust-lang.org/dist/2023-12-05/index.html. You can leave feedback on the internals thread. The release team is also thinking about

 
11 hours later…
12:01
No one can advice how to solve my problem described above?
I think, that I could ask about it on SO?
To be fair, I still don't understand what the problem is. :(
@E_net4 Wait a moment, I'll try to properly formulate it
My english is a ... :)
I have a csv-file, which looks like this:
let csv = "name,age
	Anna,30
	Helen, 40
    Joe,32";
I want to interact with this file not line-by-line, but in desired order.
F.e.: Input: Enter worker’s name: Helen
Output: Helen’s age: 40
12:20
You seem to want to read until you find what you are looking for. Iterators have find.
Alternatively, keep the contents of the CSV in a dictionary in memory, so that any subsequent look-ups do not need to read the file multiple times.
Yes. Wait please, If you have a time, I'll try a find
One moment :)
if record.iter().find(|field| field == &query1.trim()).is_some()
Same result
It is still not clear what you mean by "same result" or "same story". What was the outcome and what did you expect to happen instead?
I have wanted to say that it works as previously
If anything, you might be having trouble with the fact that csv gives you an iterator of records, which in turn provide an iterator for each field.
Outcome was: Invalid input. Please try again
12:29
So you may need two levels of find: one to find the record, and within that one a find to get the name field.
mm
double find? can you write an example how it can looks (even not for my example)
Just a find where the closure within would have another find. But maybe you don't need this. Field values should appear in a consistent order.
Hey, you're lucky. The Rust Playground includes csv, so you can build a complete example there and share it here.
I'll try. If my problem will be alive, I'll build a complete example and share it here.
 
2 hours later…
14:49
@E_net4 Eh, I didn't make in by myself. Link to playground
As I said before: I want to find the record -> to do something with value from it -> exit
15:04
@manro You were already finding the record. You mostly forgot to break out of the loop. play.rust-lang.org/…
@E_net4 Thanks! I am mad that I'm dumb as hell :)
use csv::Error;
use std::collections::HashMap;

fn main() -> Result<(), Error> {
    let data = r#"name,age
Anna,50
Helen,20
Joe,3"#;

    let rdr = csv::ReaderBuilder::new().from_reader(data.as_bytes());

    let records = rdr
        .into_deserialize()
        .collect::<Result<HashMap<String, usize>, _>>()?;

    let query = "Helen";

    if let Some(age) = records.get(query) {
        println!("{}", age);
    } else {
        println!("Invalid input.  Please try again");
    }
    Ok(())
}
@Stargateur Thanks too. Your solutions are always more advanced :)
 
6 hours later…
20:42
A poll: When was your turning point in the way of learning Rust? :-)
I know, that we have different knowledge and experience, but it is interesting.

« first day (3339 days earlier)      last day (363 days later) »