Move unsafe code behind a (enabled by default) feature flag
notgull opened this issue · 5 comments
I am using this crate in a crate that is forbid(unsafe_code)
, where I would like to reduce the amount of unsafe code in my dependency tree. The unsafe code currently in this crate could be eliminated.
I propose an unchecked
feature. When enabled, the get_unchecked
and other methods that require unsafe
are exposed. When disabled, this crate becomes forbid(unsafe_code)
. This feature would be enabled by default to prevent breaking changes.
I am willing to implement this feature myself.
features should be additive and we cannot use features to disable APIs.
Oh, sorry, you seem to be suggesting an additive feature that is enabled by default. However, note that for users using slab with default-features = false
the approach you suggest is also a breaking change.
Hmm, that's a pickle. I'd rather not introduce a breaking change unless there's already an upcoming breaking change planned. I guess I could just write the PR and wait for version 0.5 for it to be merged.
(At this time there are no plans for 0.5...)
We are unlikely to have a breaking release any time soon, so your PR would probably sit around for at least a year. Additionally, I don't really think there's any value in a feature like this. None of the internals use unsafe besides the methods that are unsafe to call, so if you don't call those, you aren't using any unsafe code.