Open
Description
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
- ACP: Add NonZeroXxx::from_mut libs-team#129
- Implementation: Added NonZeroXxx::from_mut(_unchecked)? #103730
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- None yet.