I'm struggling to work out how to use the Result types you get back from functions that return results.
If i use "if let" the variable seems to be inside the scope of the if statement so cant be accessed after it ends.
Same with match
A lot of examples I see just use .unwrap() but then say don't use this in a real world app as it could crash if you get an error. So what is the correct way to deal with this ?
I'm playing with tantivy and ended up doing this. cheers for the help.
let index_res = tantivy::Index::open_in_dir(dir);
let index = match index_res {
Ok(index) => index,
Err(_e) => {
println!("Could not open index");
return;
}
};