Skip to content

NonZero* type constructors should be const fn #58732

Closed
@dhardy

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)
};

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-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions