Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 of 4 tasks
SOF3 opened this issue Dec 30, 2022 · 2 comments
Open
2 of 4 tasks
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@SOF3
Copy link
Contributor

SOF3 commented Dec 30, 2022

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

@SOF3 SOF3 added C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Dec 30, 2022
@asquared31415

This comment was marked as resolved.

@SOF3

This comment was marked as resolved.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 20, 2024
…lacrum,dtolnay

Added NonZeroXxx::from_mut(_unchecked)?

ACP: rust-lang/libs-team#129
Tracking issue: rust-lang#106290
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jan 20, 2024
Rollup merge of rust-lang#103730 - SOF3:nonzero-from-mut, r=Mark-Simulacrum,dtolnay

Added NonZeroXxx::from_mut(_unchecked)?

ACP: rust-lang/libs-team#129
Tracking issue: rust-lang#106290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants