? — propagate error. .unwrap() — panic on error.
?:
.unwrap():
1// ? — safe error propagation2fn read_file() -> Result<String, io::Error> {3 let content = std::fs::read_to_string("file.txt")?;4 Ok(content)5}67// .unwrap() — panics on error8fn read_file_unsafe() -> String {9 std::fs::read_to_string("file.txt").unwrap()10}
Key: ? for production, unwrap for testing.