The script is a literally a result of my having read half of the Rust book and then battled the borrow checker until the thing compiled. I don't know any Rust programmers personally, so I'd really appreciate it if someone could take a look at the code and tell me what I'm doing wrong.
For context, I'm a data engineer who works mainly with Python and SQL, and am looking to learn some Rust to speed up the bottlenecks in my code. I have zero experience in systems programming languages.
if let Some(x) = &column_log.max_invalid {
max_val = x.clone();
}
(Basically if you're writing None => {} that's a good hint to take a look at whether there's another way you can do that.)
As an entirely "your milage may vary", thing, I saw
let empty_vec: Vec<String> = Vec::new();
let empty_string = "".to_string();
let mut column_map = HashMap::new();
You can also write String::new() to get an empty string, if you prefer that.
"".to_string(), String::new(), "".to_owned(), String::default(), etc are all fine, so it's just a style choice. But if you like Vec::new() over vec![], then I thought you might like String::new() in that snippit too.
I only gave it a brief look over, but one thing that you may want to know about is the crate anyhow. Since it seems that for the most part you are just bubbling these errors up to main and printing it out. Keep up the good work
Thanks for the tip. Error handling in Rust is one of the things that I'm having trouble getting my head around, and after a look through the anyhow docs, what it does still isn't entirely clear to me. What would be the advantage of using anyhow over the way the error handling is currently being handled in the code?