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
Feature gate:
#![feature(nonzero_from_mut)]This is a tracking issue for the associated functions
NonZeroXxx::from_mutandNonZeroXxx::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
Steps / History
Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩