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

Add generic NonZero type. #100428

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 33 additions & 24 deletions compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -980,43 +980,52 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expr_ty: Ty<'tcx>,
) -> bool {
let tcx = self.tcx;
let (adt, unwrap) = match expected.kind() {
let (adt, substs, unwrap) = match expected.kind() {
// In case Option<NonZero*> is wanted, but * is provided, suggest calling new
ty::Adt(adt, substs) if tcx.is_diagnostic_item(sym::Option, adt.did()) => {
// Unwrap option
let ty::Adt(adt, _) = substs.type_at(0).kind() else { return false; };

(adt, "")
let nonzero_type = substs.type_at(0); // Unwrap option type.
let ty::Adt(adt, substs) = nonzero_type.kind() else { return false; };
(adt, substs, "")
}
// In case NonZero* is wanted, but * is provided also add `.unwrap()` to satisfy types
ty::Adt(adt, _) => (adt, ".unwrap()"),
// In case `NonZero<*>` is wanted but `*` is provided, also add `.unwrap()` to satisfy types.
ty::Adt(adt, substs) => (adt, substs, ".unwrap()"),
_ => return false,
};

let map = [
(sym::NonZeroU8, tcx.types.u8),
(sym::NonZeroU16, tcx.types.u16),
(sym::NonZeroU32, tcx.types.u32),
(sym::NonZeroU64, tcx.types.u64),
(sym::NonZeroU128, tcx.types.u128),
(sym::NonZeroI8, tcx.types.i8),
(sym::NonZeroI16, tcx.types.i16),
(sym::NonZeroI32, tcx.types.i32),
(sym::NonZeroI64, tcx.types.i64),
(sym::NonZeroI128, tcx.types.i128),
if !self.tcx.is_diagnostic_item(sym::NonZero, adt.did()) {
return false;
}

let coercable_types = [
("NonZeroU8", tcx.types.u8),
("NonZeroU16", tcx.types.u16),
("NonZeroU32", tcx.types.u32),
("NonZeroU64", tcx.types.u64),
("NonZeroU128", tcx.types.u128),
("NonZeroI8", tcx.types.i8),
("NonZeroI16", tcx.types.i16),
("NonZeroI32", tcx.types.i32),
("NonZeroI64", tcx.types.i64),
("NonZeroI128", tcx.types.i128),
];

let Some((s, _)) = map
let int_type = substs.type_at(0);

let Some(nonzero_alias) = coercable_types
.iter()
.find(|&&(s, t)| self.tcx.is_diagnostic_item(s, adt.did()) && self.can_coerce(expr_ty, t))
.find_map(|(nonzero_alias, t)| {
if *t == int_type && self.can_coerce(expr_ty, *t) {
Some(nonzero_alias)
} else {
None
}
})
else { return false; };

let path = self.tcx.def_path_str(adt.non_enum_variant().def_id);

err.multipart_suggestion(
format!("consider calling `{s}::new`"),
format!("consider calling `{nonzero_alias}::new`"),
vec![
(expr.span.shrink_to_lo(), format!("{path}::new(")),
(expr.span.shrink_to_lo(), format!("{nonzero_alias}::new(")),
(expr.span.shrink_to_hi(), format!("){unwrap}")),
],
Applicability::MaybeIncorrect,
Expand Down
11 changes: 1 addition & 10 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,7 @@ symbols! {
Mutex,
MutexGuard,
N,
NonZeroI128,
NonZeroI16,
NonZeroI32,
NonZeroI64,
NonZeroI8,
NonZeroU128,
NonZeroU16,
NonZeroU32,
NonZeroU64,
NonZeroU8,
NonZero,
None,
Ok,
Option,
Expand Down
51 changes: 25 additions & 26 deletions library/core/src/cmp/bytewise.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::num::{NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize};
use crate::num::{NonZeroU128, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize};
use crate::num::NonZero;

/// Types where `==` & `!=` are equivalent to comparing their underlying bytes.
///
Expand Down Expand Up @@ -36,37 +35,37 @@ is_bytewise_comparable!(bool, char, super::Ordering);
// SAFETY: Similarly, the non-zero types have a niche, but no undef and no pointers,
// and they compare like their underlying numeric type.
is_bytewise_comparable!(
NonZeroU8,
NonZeroU16,
NonZeroU32,
NonZeroU64,
NonZeroU128,
NonZeroUsize,
NonZeroI8,
NonZeroI16,
NonZeroI32,
NonZeroI64,
NonZeroI128,
NonZeroIsize,
NonZero<u8>,
NonZero<u16>,
NonZero<u32>,
NonZero<u64>,
NonZero<u128>,
NonZero<usize>,
NonZero<i8>,
NonZero<i16>,
NonZero<i32>,
NonZero<i64>,
NonZero<i128>,
NonZero<isize>,
);

// SAFETY: The NonZero types have the "null" optimization guaranteed, and thus
// are also safe to equality-compare bitwise inside an `Option`.
// The way `PartialOrd` is defined for `Option` means that this wouldn't work
// for `<` or `>` on the signed types, but since we only do `==` it's fine.
is_bytewise_comparable!(
Option<NonZeroU8>,
Option<NonZeroU16>,
Option<NonZeroU32>,
Option<NonZeroU64>,
Option<NonZeroU128>,
Option<NonZeroUsize>,
Option<NonZeroI8>,
Option<NonZeroI16>,
Option<NonZeroI32>,
Option<NonZeroI64>,
Option<NonZeroI128>,
Option<NonZeroIsize>,
Option<NonZero<u8>>,
Option<NonZero<u16>>,
Option<NonZero<u32>>,
Option<NonZero<u64>>,
Option<NonZero<u128>>,
Option<NonZero<usize>>,
Option<NonZero<i8>>,
Option<NonZero<i16>>,
Option<NonZero<i32>>,
Option<NonZero<i64>>,
Option<NonZero<i128>>,
Option<NonZero<isize>>,
);

macro_rules! is_bytewise_comparable_array_length {
Expand Down
155 changes: 84 additions & 71 deletions library/core/src/convert/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,18 +408,7 @@ mod ptr_try_from_impls {
}

// Conversion traits for non-zero integer types
use crate::num::NonZeroI128;
use crate::num::NonZeroI16;
use crate::num::NonZeroI32;
use crate::num::NonZeroI64;
use crate::num::NonZeroI8;
use crate::num::NonZeroIsize;
use crate::num::NonZeroU128;
use crate::num::NonZeroU16;
use crate::num::NonZeroU32;
use crate::num::NonZeroU64;
use crate::num::NonZeroU8;
use crate::num::NonZeroUsize;
use crate::num::NonZero;

macro_rules! nzint_impl_from {
($Small: ty, $Large: ty, #[$attr:meta], $doc: expr) => {
Expand Down Expand Up @@ -450,45 +439,45 @@ macro_rules! nzint_impl_from {
}

// Non-zero Unsigned -> Non-zero Unsigned
nzint_impl_from! { NonZeroU8, NonZeroU16, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU8, NonZeroU32, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU8, NonZeroU64, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU8, NonZeroU128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU8, NonZeroUsize, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU16, NonZeroU32, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU16, NonZeroU64, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU16, NonZeroU128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU16, NonZeroUsize, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU32, NonZeroU64, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU32, NonZeroU128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU64, NonZeroU128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u8>, NonZero<u16>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u8>, NonZero<u32>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u8>, NonZero<u64>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u8>, NonZero<u128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u8>, NonZero<usize>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u16>, NonZero<u32>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u16>, NonZero<u64>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u16>, NonZero<u128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u16>, NonZero<usize>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u32>, NonZero<u64>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u32>, NonZero<u128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u64>, NonZero<u128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }

// Non-zero Signed -> Non-zero Signed
nzint_impl_from! { NonZeroI8, NonZeroI16, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI8, NonZeroI32, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI8, NonZeroI64, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI8, NonZeroI128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI8, NonZeroIsize, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI16, NonZeroI32, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI16, NonZeroI64, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI16, NonZeroI128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI16, NonZeroIsize, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI32, NonZeroI64, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI32, NonZeroI128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroI64, NonZeroI128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i8>, NonZero<i16>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i8>, NonZero<i32>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i8>, NonZero<i64>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i8>, NonZero<i128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i8>, NonZero<isize>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i16>, NonZero<i32>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i16>, NonZero<i64>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i16>, NonZero<i128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i16>, NonZero<isize>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i32>, NonZero<i64>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i32>, NonZero<i128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<i64>, NonZero<i128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }

// NonZero UnSigned -> Non-zero Signed
nzint_impl_from! { NonZeroU8, NonZeroI16, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU8, NonZeroI32, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU8, NonZeroI64, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU8, NonZeroI128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU8, NonZeroIsize, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU16, NonZeroI32, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU16, NonZeroI64, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU16, NonZeroI128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU32, NonZeroI64, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU32, NonZeroI128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZeroU64, NonZeroI128, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u8>, NonZero<i16>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u8>, NonZero<i32>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u8>, NonZero<i64>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u8>, NonZero<i128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u8>, NonZero<isize>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u16>, NonZero<i32>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u16>, NonZero<i64>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u16>, NonZero<i128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u32>, NonZero<i64>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u32>, NonZero<i128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }
nzint_impl_from! { NonZero<u64>, NonZero<i128>, #[stable(feature = "nz_int_conv", since = "1.41.0")] }

macro_rules! nzint_impl_try_from_int {
($Int: ty, $NonZeroInt: ty, #[$attr:meta], $doc: expr) => {
Expand Down Expand Up @@ -518,18 +507,18 @@ macro_rules! nzint_impl_try_from_int {
}

// Int -> Non-zero Int
nzint_impl_try_from_int! { u8, NonZeroU8, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { u16, NonZeroU16, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { u32, NonZeroU32, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { u64, NonZeroU64, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { u128, NonZeroU128, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { usize, NonZeroUsize, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { i8, NonZeroI8, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { i16, NonZeroI16, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { i32, NonZeroI32, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { i64, NonZeroI64, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { i128, NonZeroI128, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { isize, NonZeroIsize, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { u8, NonZero<u8>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { u16, NonZero<u16>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { u32, NonZero<u32>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { u64, NonZero<u64>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { u128, NonZero<u128>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { usize, NonZero<usize>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { i8, NonZero<i8>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { i16, NonZero<i16>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { i32, NonZero<i32>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { i64, NonZero<i64>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { i128, NonZero<i128>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }
nzint_impl_try_from_int! { isize, NonZero<isize>, #[stable(feature = "nzint_try_from_int_conv", since = "1.46.0")] }

macro_rules! nzint_impl_try_from_nzint {
($From:ty => $To:ty, $doc: expr) => {
Expand Down Expand Up @@ -564,17 +553,41 @@ macro_rules! nzint_impl_try_from_nzint {
}

// Non-zero int -> non-zero unsigned int
nzint_impl_try_from_nzint! { NonZeroU8: NonZeroI8, NonZeroU16, NonZeroI16, NonZeroU32, NonZeroI32, NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize }
nzint_impl_try_from_nzint! { NonZeroU16: NonZeroI8, NonZeroI16, NonZeroU32, NonZeroI32, NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize }
nzint_impl_try_from_nzint! { NonZeroU32: NonZeroI8, NonZeroI16, NonZeroI32, NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize }
nzint_impl_try_from_nzint! { NonZeroU64: NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize }
nzint_impl_try_from_nzint! { NonZeroU128: NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroUsize, NonZeroIsize }
nzint_impl_try_from_nzint! { NonZeroUsize: NonZeroI8, NonZeroI16, NonZeroU32, NonZeroI32, NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroIsize }
nzint_impl_try_from_nzint! {
NonZero<u8>: NonZero<i8>, NonZero<u16>, NonZero<i16>, NonZero<u32>, NonZero<i32>, NonZero<u64>, NonZero<i64>, NonZero<u128>, NonZero<i128>, NonZero<usize>, NonZero<isize>
}
nzint_impl_try_from_nzint! {
NonZero<u16>: NonZero<i8>, NonZero<i16>, NonZero<u32>, NonZero<i32>, NonZero<u64>, NonZero<i64>, NonZero<u128>, NonZero<i128>, NonZero<usize>, NonZero<isize>
}
nzint_impl_try_from_nzint! {
NonZero<u32>: NonZero<i8>, NonZero<i16>, NonZero<i32>, NonZero<u64>, NonZero<i64>, NonZero<u128>, NonZero<i128>, NonZero<usize>, NonZero<isize>
}
nzint_impl_try_from_nzint! {
NonZero<u64>: NonZero<i8>, NonZero<i16>, NonZero<i32>, NonZero<i64>, NonZero<u128>, NonZero<i128>, NonZero<usize>, NonZero<isize>
}
nzint_impl_try_from_nzint! {
NonZero<u128>: NonZero<i8>, NonZero<i16>, NonZero<i32>, NonZero<i64>, NonZero<i128>, NonZero<usize>, NonZero<isize>
}
nzint_impl_try_from_nzint! {
NonZero<usize>: NonZero<i8>, NonZero<i16>, NonZero<u32>, NonZero<i32>, NonZero<u64>, NonZero<i64>, NonZero<u128>, NonZero<i128>, NonZero<isize>
}

// Non-zero int -> non-zero signed int
nzint_impl_try_from_nzint! { NonZeroI8: NonZeroU8, NonZeroU16, NonZeroI16, NonZeroU32, NonZeroI32, NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize }
nzint_impl_try_from_nzint! { NonZeroI16: NonZeroU16, NonZeroU32, NonZeroI32, NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize }
nzint_impl_try_from_nzint! { NonZeroI32: NonZeroU32, NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize }
nzint_impl_try_from_nzint! { NonZeroI64: NonZeroU64, NonZeroU128, NonZeroI128, NonZeroUsize, NonZeroIsize }
nzint_impl_try_from_nzint! { NonZeroI128: NonZeroU128, NonZeroUsize, NonZeroIsize }
nzint_impl_try_from_nzint! { NonZeroIsize: NonZeroU16, NonZeroU32, NonZeroI32, NonZeroU64, NonZeroI64, NonZeroU128, NonZeroI128, NonZeroUsize }
nzint_impl_try_from_nzint! {
NonZero<i8>: NonZero<u8>, NonZero<u16>, NonZero<i16>, NonZero<u32>, NonZero<i32>, NonZero<u64>, NonZero<i64>, NonZero<u128>, NonZero<i128>, NonZero<usize>, NonZero<isize>
}
nzint_impl_try_from_nzint! {
NonZero<i16>: NonZero<u16>, NonZero<u32>, NonZero<i32>, NonZero<u64>, NonZero<i64>, NonZero<u128>, NonZero<i128>, NonZero<usize>, NonZero<isize>
}
nzint_impl_try_from_nzint! {
NonZero<i32>: NonZero<u32>, NonZero<u64>, NonZero<i64>, NonZero<u128>, NonZero<i128>, NonZero<usize>, NonZero<isize>
}
nzint_impl_try_from_nzint! {
NonZero<i64>: NonZero<u64>, NonZero<u128>, NonZero<i128>, NonZero<usize>, NonZero<isize>
}
nzint_impl_try_from_nzint! {
NonZero<i128>: NonZero<u128>, NonZero<usize>, NonZero<isize>
}
nzint_impl_try_from_nzint! {
NonZero<isize>: NonZero<u16>, NonZero<u32>, NonZero<i32>, NonZero<u64>, NonZero<i64>, NonZero<u128>, NonZero<i128>, NonZero<usize>
}
Loading