You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exposure of confidential data (such as the project path, which generally contains the OS user's name), since unwrap() integrates the complete path of the source file into the final executable.
Advantage
more stable code
improved confidentiality
the final executable will be smaller, since it won't include the path strings for panic.
Drawbacks
No response
Example
let str = "1000".to_string();let number = str.parse::<i32>().unwrap();//<------ risk of uncontrolled exception if str does not contain a number
Could be written as:
let number = match str.parse::<i32>(){Ok(n) => n,Err(_) => todo!(),};
thank you in advance :
The text was updated successfully, but these errors were encountered:
What it does
using unwrap() in code exposes it to two risks:
Advantage
Drawbacks
No response
Example
Could be written as:
thank you in advance :
The text was updated successfully, but these errors were encountered: