Skip to content

Commit

Permalink
Hide implementation details for NonZero auto traits.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Mar 2, 2024
1 parent 3673ebf commit b994f47
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions library/core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::marker::StructuralPartialEq;
use crate::ops::{BitOr, BitOrAssign, Div, Neg, Rem};
use crate::ptr;
use crate::str::FromStr;
use crate::panic::{RefUnwindSafe, UnwindSafe};

use super::from_str_radix;
use super::{IntErrorKind, ParseIntError};
Expand Down Expand Up @@ -129,6 +130,21 @@ impl_nonzero_fmt!(Octal);
impl_nonzero_fmt!(LowerHex);
impl_nonzero_fmt!(UpperHex);

macro_rules! impl_nonzero_auto_trait {
($Trait:ident) => {
#[stable(feature = "nonzero", since = "1.28.0")]
unsafe impl<T> $Trait for NonZero<T> where T: ZeroablePrimitive + $Trait {}
};
}

// Implement auto-traits manually based on `T` to avoid docs exposing
// the `ZeroablePrimitive::NonZeroInner` implementation detail.
impl_nonzero_auto_trait!(RefUnwindSafe);
impl_nonzero_auto_trait!(Send);
impl_nonzero_auto_trait!(Sync);
impl_nonzero_auto_trait!(Unpin);
impl_nonzero_auto_trait!(UnwindSafe);

#[stable(feature = "nonzero", since = "1.28.0")]
impl<T> Clone for NonZero<T>
where
Expand Down

0 comments on commit b994f47

Please sign in to comment.