Skip to navigation
Error handeling with
14.09.22
Rust does not have exceptions. It uses the Result enum, which is a part of the Rust standard library and is used to represent either success (Ok) or failure (Err): enum Result
{ Ok(T), Err(E), } example: let file = fs::read_to_string(&path).await.unwrap(); let t = json::parse(&file); match t { Ok(i) => println!("ok"), Err(e) => println!("failed"), };
https://betterprogramming.pub/rust-error-handling-84e7bd169e47
Reply
Anonymous
Information Epoch 1742413032
Design for visibility.
Home
Notebook
Contact us