Skip to content

Consider removing unsafe code #47

Description

@mikwielgus

This crate contains unsafe code in a few places to bypass non-zero checks in NonZeroU32 type: unsafe { NonZeroU32::new_unchecked(...) }.

Consider removing the unsafe code and instead just using NonZeroU32::new(...) and panicking if it returns None, or at least providing code paths that can be used by the user without running any unsafe code.

Making this change is unlikely to make any meaningful difference in performance: a non-zero check is an operation that is about as cheap as it gets. In practice, collection performance is dominated by cache and memory effects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions