Skip to content

NonZero* type constructors should be const fn #58732

Description

@dhardy

E.g. NonZeroU32::new_unchecked is a const fn but NonZeroU32::new is not; this means that defining constant values is unsafe.

pub const X: NonZeroU32 = unsafe {
    NonZeroU32::new_unchecked(123)
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions