-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forbid unsafe code #432
Comments
I think it worth mentioning that being over-zealous against unsafe is as harmful as the other extreme. The point of But if I find a strong incentive to use (Disclaimer: |
That's to prevent to happen by accident. Unsafe is a tool, to be used mainly in ffi, low level code and performance optimization. I never had to use the later, and I write at work mainly CPU bound programs. I definitively think structopt will never need unsafe. |
@CreepySkeleton I agree that unsafe has its place. But having a small barrier to add 1 line of unsafe code to an otherwise clean project is always good. Makes you think twice if it is really needed. So just because someone did not want to take a good look at the problem, or having just one line in of unsafe just to shave of 0.1ms of speed is not what we want (in most cases). And yet it is sometimes used this way. I also don't expect As @TeXitoi pointed out most low level or FFI code use unsafe functions (as it is just needed sometimes). But for most higher level crates it is not really needed. So yes I agree, and changing the geiger list from red/white to green while having the same functionality is also not bad 😄 . Having unsafe code has its downsides. Like this has to have at least some memory issues with all that unsafe code. But al least Thanks for adding the line/fix so quickly (and even having a new shiny badge I see 😉 ) and thanks for the wonderful crate too! ❤️ |
structopt
does not seem to use unsafe code, which is very good :)To prevent this from ever happening, add following line to the top:
#![forbid(unsafe_code)]
of https://github.com/TeXitoi/structopt/blob/master/src/lib.rs
and https://github.com/TeXitoi/structopt/blob/master/structopt-derive/src/lib.rs
This will make the package green in
https://github.com/rust-secure-code/cargo-geiger
The text was updated successfully, but these errors were encountered: