Hello,
is it possible to add a directive prohibiting the use of unwrap() without exception control?
like : #![forbid(unsafe_code)]
for example, have something like this:
#![forbid(unwrap)]
I think unwrap should only be used for prototyping or test creation.
Problems with "unwrap()" :
- Risk of instability, due to uncontrolled exceptions
- Heavier final executable, since it contains file path strings for exceptions (panic)
- Exposure of sensitive data, developer identity or project file structure; unwrap() adds code containing file paths, so it records in the final executable all data that could determine the origin of the exception, including the complete path of the source files, which gives the developer's name: ex:
/home/{user_name}/project/XXXX/file.rs
more details -> here <-
To verify what I'm saying, you can display all the strings contained in the executable like this: (linux cmd)
cargo build --release
strings ./target/release/{{ project(.exe) }} > str.txt
vi str.txt
I also posted a proposal for cargo clippy
here :
I think it will allow good practices, such as the use of Match or unwrap_or()...
Thanks to the whole community and to the people who take care of the development of this great language