Skip to content

Tracking Issue for NonZeroXxx::from_mut/from_mut_unchecked (nonzero_from_mut) #106290

Description

@SOF3

Feature gate: #![feature(nonzero_from_mut)]

This is a tracking issue for the associated functions NonZeroXxx::from_mut and NonZeroXxx::from_mut_unchecked.

These associated functions allow converting a mutable reference to a primitive integer (&mut xxx) into the equivalent &mut NonZeroXxx, with or without validation. The safety is guaranteed by the mutable reference, but currently there is no way to perform this conversion without relying on an unsafe transparent cast.

Public API

// core::num

// $NonZeroInt is one of all signed and unsigned non-zero integer types in core::num,
// and $int is the corresponding primitive type.
impl $NonZeroInt {
    pub fn from_mut(n: &mut $int) -> Option<&mut $NonZeroInt>;
    pub unsafe fn from_mut_unchecked(n: &mut int) -> &mut $NonZeroInt;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩

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

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libsRelevant to the library 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