1#[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")]
6#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
7pub impl(self) const trait TruncateTarget<Target> {
8 #[doc(hidden)]
9 fn internal_truncate(self) -> Target;
10
11 #[doc(hidden)]
12 fn internal_saturating_truncate(self) -> Target;
13
14 #[doc(hidden)]
15 fn internal_checked_truncate(self) -> Option<Target>;
16}
17
18#[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")]
20#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
21pub impl(self) const trait WidenTarget<Target> {
22 #[doc(hidden)]
23 fn internal_widen(self) -> Target;
24}
25
26macro_rules! impl_truncate {
27 ($($from:ty => $($to:ty),+;)*) => {$($(
28 const _: () = assert!(
29 size_of::<$from>() >= size_of::<$to>(),
30 concat!(
31 "cannot truncate ",
32 stringify!($from),
33 " to ",
34 stringify!($to),
35 " because ",
36 stringify!($from),
37 " is smaller than ",
38 stringify!($to)
39 )
40 );
41
42 #[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")]
43 #[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
44 const impl TruncateTarget<$to> for $from {
45 #[inline]
46 fn internal_truncate(self) -> $to {
47 self as _
48 }
49
50 #[inline]
51 fn internal_saturating_truncate(self) -> $to {
52 if self > <$to>::MAX as Self {
53 <$to>::MAX
54 } else if self < <$to>::MIN as Self {
55 <$to>::MIN
56 } else {
57 self as _
58 }
59 }
60
61 #[inline]
62 fn internal_checked_truncate(self) -> Option<$to> {
63 if self > <$to>::MAX as Self || self < <$to>::MIN as Self {
64 None
65 } else {
66 Some(self as _)
67 }
68 }
69 }
70 )+)*};
71}
72
73macro_rules! impl_widen {
74 ($($from:ty => $($to:ty),+;)*) => {$($(
75 const _: () = assert!(
76 size_of::<$from>() <= size_of::<$to>(),
77 concat!(
78 "cannot widen ",
79 stringify!($from),
80 " to ",
81 stringify!($to),
82 " because ",
83 stringify!($from),
84 " is larger than ",
85 stringify!($to)
86 )
87 );
88
89 #[unstable(feature = "num_internals", reason = "internal implementation detail", issue = "none")]
90 #[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
91 const impl WidenTarget<$to> for $from {
92 fn internal_widen(self) -> $to {
93 self as _
94 }
95 }
96 )+)*};
97}
98
99const _: () =
if !(size_of::<u8>() >= size_of::<u8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u8 to u8 because u8 is smaller than u8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u8> for u8 {
#[inline]
fn internal_truncate(self) -> u8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u8 {
if self > <u8>::MAX as Self {
<u8>::MAX
} else if self < <u8>::MIN as Self { <u8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u8> {
if self > <u8>::MAX as Self || self < <u8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u16>() >= size_of::<u16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u16 to u16 because u16 is smaller than u16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u16> for u16 {
#[inline]
fn internal_truncate(self) -> u16 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u16 {
if self > <u16>::MAX as Self {
<u16>::MAX
} else if self < <u16>::MIN as Self { <u16>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u16> {
if self > <u16>::MAX as Self || self < <u16>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u16>() >= size_of::<u8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u16 to u8 because u16 is smaller than u8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u8> for u16 {
#[inline]
fn internal_truncate(self) -> u8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u8 {
if self > <u8>::MAX as Self {
<u8>::MAX
} else if self < <u8>::MIN as Self { <u8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u8> {
if self > <u8>::MAX as Self || self < <u8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u32>() >= size_of::<u32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u32 to u32 because u32 is smaller than u32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u32> for u32 {
#[inline]
fn internal_truncate(self) -> u32 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u32 {
if self > <u32>::MAX as Self {
<u32>::MAX
} else if self < <u32>::MIN as Self { <u32>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u32> {
if self > <u32>::MAX as Self || self < <u32>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u32>() >= size_of::<u16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u32 to u16 because u32 is smaller than u16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u16> for u32 {
#[inline]
fn internal_truncate(self) -> u16 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u16 {
if self > <u16>::MAX as Self {
<u16>::MAX
} else if self < <u16>::MIN as Self { <u16>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u16> {
if self > <u16>::MAX as Self || self < <u16>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u32>() >= size_of::<u8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u32 to u8 because u32 is smaller than u8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u8> for u32 {
#[inline]
fn internal_truncate(self) -> u8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u8 {
if self > <u8>::MAX as Self {
<u8>::MAX
} else if self < <u8>::MIN as Self { <u8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u8> {
if self > <u8>::MAX as Self || self < <u8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u64>() >= size_of::<u64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u64 to u64 because u64 is smaller than u64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u64> for u64 {
#[inline]
fn internal_truncate(self) -> u64 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u64 {
if self > <u64>::MAX as Self {
<u64>::MAX
} else if self < <u64>::MIN as Self { <u64>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u64> {
if self > <u64>::MAX as Self || self < <u64>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u64>() >= size_of::<u32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u64 to u32 because u64 is smaller than u32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u32> for u64 {
#[inline]
fn internal_truncate(self) -> u32 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u32 {
if self > <u32>::MAX as Self {
<u32>::MAX
} else if self < <u32>::MIN as Self { <u32>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u32> {
if self > <u32>::MAX as Self || self < <u32>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u64>() >= size_of::<u16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u64 to u16 because u64 is smaller than u16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u16> for u64 {
#[inline]
fn internal_truncate(self) -> u16 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u16 {
if self > <u16>::MAX as Self {
<u16>::MAX
} else if self < <u16>::MIN as Self { <u16>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u16> {
if self > <u16>::MAX as Self || self < <u16>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u64>() >= size_of::<u8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u64 to u8 because u64 is smaller than u8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u8> for u64 {
#[inline]
fn internal_truncate(self) -> u8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u8 {
if self > <u8>::MAX as Self {
<u8>::MAX
} else if self < <u8>::MIN as Self { <u8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u8> {
if self > <u8>::MAX as Self || self < <u8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u128>() >= size_of::<u128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u128 to u128 because u128 is smaller than u128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u128> for u128 {
#[inline]
fn internal_truncate(self) -> u128 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u128 {
if self > <u128>::MAX as Self {
<u128>::MAX
} else if self < <u128>::MIN as Self {
<u128>::MIN
} else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u128> {
if self > <u128>::MAX as Self || self < <u128>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u128>() >= size_of::<u64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u128 to u64 because u128 is smaller than u64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u64> for u128 {
#[inline]
fn internal_truncate(self) -> u64 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u64 {
if self > <u64>::MAX as Self {
<u64>::MAX
} else if self < <u64>::MIN as Self { <u64>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u64> {
if self > <u64>::MAX as Self || self < <u64>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u128>() >= size_of::<u32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u128 to u32 because u128 is smaller than u32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u32> for u128 {
#[inline]
fn internal_truncate(self) -> u32 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u32 {
if self > <u32>::MAX as Self {
<u32>::MAX
} else if self < <u32>::MIN as Self { <u32>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u32> {
if self > <u32>::MAX as Self || self < <u32>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u128>() >= size_of::<u16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u128 to u16 because u128 is smaller than u16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u16> for u128 {
#[inline]
fn internal_truncate(self) -> u16 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u16 {
if self > <u16>::MAX as Self {
<u16>::MAX
} else if self < <u16>::MIN as Self { <u16>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u16> {
if self > <u16>::MAX as Self || self < <u16>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<u128>() >= size_of::<u8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate u128 to u8 because u128 is smaller than u8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u8> for u128 {
#[inline]
fn internal_truncate(self) -> u8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u8 {
if self > <u8>::MAX as Self {
<u8>::MAX
} else if self < <u8>::MIN as Self { <u8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u8> {
if self > <u8>::MAX as Self || self < <u8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<usize>() >= size_of::<usize>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate usize to usize because usize is smaller than usize"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<usize> for usize {
#[inline]
fn internal_truncate(self) -> usize { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> usize {
if self > <usize>::MAX as Self {
<usize>::MAX
} else if self < <usize>::MIN as Self {
<usize>::MIN
} else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<usize> {
if self > <usize>::MAX as Self || self < <usize>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<usize>() >= size_of::<u16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate usize to u16 because usize is smaller than u16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u16> for usize {
#[inline]
fn internal_truncate(self) -> u16 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u16 {
if self > <u16>::MAX as Self {
<u16>::MAX
} else if self < <u16>::MIN as Self { <u16>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u16> {
if self > <u16>::MAX as Self || self < <u16>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<usize>() >= size_of::<u8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate usize to u8 because usize is smaller than u8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<u8> for usize {
#[inline]
fn internal_truncate(self) -> u8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> u8 {
if self > <u8>::MAX as Self {
<u8>::MAX
} else if self < <u8>::MIN as Self { <u8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<u8> {
if self > <u8>::MAX as Self || self < <u8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i8>() >= size_of::<i8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i8 to i8 because i8 is smaller than i8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i8> for i8 {
#[inline]
fn internal_truncate(self) -> i8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i8 {
if self > <i8>::MAX as Self {
<i8>::MAX
} else if self < <i8>::MIN as Self { <i8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i8> {
if self > <i8>::MAX as Self || self < <i8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i16>() >= size_of::<i16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i16 to i16 because i16 is smaller than i16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i16> for i16 {
#[inline]
fn internal_truncate(self) -> i16 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i16 {
if self > <i16>::MAX as Self {
<i16>::MAX
} else if self < <i16>::MIN as Self { <i16>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i16> {
if self > <i16>::MAX as Self || self < <i16>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i16>() >= size_of::<i8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i16 to i8 because i16 is smaller than i8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i8> for i16 {
#[inline]
fn internal_truncate(self) -> i8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i8 {
if self > <i8>::MAX as Self {
<i8>::MAX
} else if self < <i8>::MIN as Self { <i8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i8> {
if self > <i8>::MAX as Self || self < <i8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i32>() >= size_of::<i32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i32 to i32 because i32 is smaller than i32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i32> for i32 {
#[inline]
fn internal_truncate(self) -> i32 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i32 {
if self > <i32>::MAX as Self {
<i32>::MAX
} else if self < <i32>::MIN as Self { <i32>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i32> {
if self > <i32>::MAX as Self || self < <i32>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i32>() >= size_of::<i16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i32 to i16 because i32 is smaller than i16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i16> for i32 {
#[inline]
fn internal_truncate(self) -> i16 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i16 {
if self > <i16>::MAX as Self {
<i16>::MAX
} else if self < <i16>::MIN as Self { <i16>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i16> {
if self > <i16>::MAX as Self || self < <i16>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i32>() >= size_of::<i8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i32 to i8 because i32 is smaller than i8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i8> for i32 {
#[inline]
fn internal_truncate(self) -> i8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i8 {
if self > <i8>::MAX as Self {
<i8>::MAX
} else if self < <i8>::MIN as Self { <i8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i8> {
if self > <i8>::MAX as Self || self < <i8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i64>() >= size_of::<i64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i64 to i64 because i64 is smaller than i64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i64> for i64 {
#[inline]
fn internal_truncate(self) -> i64 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i64 {
if self > <i64>::MAX as Self {
<i64>::MAX
} else if self < <i64>::MIN as Self { <i64>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i64> {
if self > <i64>::MAX as Self || self < <i64>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i64>() >= size_of::<i32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i64 to i32 because i64 is smaller than i32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i32> for i64 {
#[inline]
fn internal_truncate(self) -> i32 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i32 {
if self > <i32>::MAX as Self {
<i32>::MAX
} else if self < <i32>::MIN as Self { <i32>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i32> {
if self > <i32>::MAX as Self || self < <i32>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i64>() >= size_of::<i16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i64 to i16 because i64 is smaller than i16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i16> for i64 {
#[inline]
fn internal_truncate(self) -> i16 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i16 {
if self > <i16>::MAX as Self {
<i16>::MAX
} else if self < <i16>::MIN as Self { <i16>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i16> {
if self > <i16>::MAX as Self || self < <i16>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i64>() >= size_of::<i8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i64 to i8 because i64 is smaller than i8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i8> for i64 {
#[inline]
fn internal_truncate(self) -> i8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i8 {
if self > <i8>::MAX as Self {
<i8>::MAX
} else if self < <i8>::MIN as Self { <i8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i8> {
if self > <i8>::MAX as Self || self < <i8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i128>() >= size_of::<i128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i128 to i128 because i128 is smaller than i128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i128> for i128 {
#[inline]
fn internal_truncate(self) -> i128 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i128 {
if self > <i128>::MAX as Self {
<i128>::MAX
} else if self < <i128>::MIN as Self {
<i128>::MIN
} else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i128> {
if self > <i128>::MAX as Self || self < <i128>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i128>() >= size_of::<i64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i128 to i64 because i128 is smaller than i64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i64> for i128 {
#[inline]
fn internal_truncate(self) -> i64 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i64 {
if self > <i64>::MAX as Self {
<i64>::MAX
} else if self < <i64>::MIN as Self { <i64>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i64> {
if self > <i64>::MAX as Self || self < <i64>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i128>() >= size_of::<i32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i128 to i32 because i128 is smaller than i32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i32> for i128 {
#[inline]
fn internal_truncate(self) -> i32 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i32 {
if self > <i32>::MAX as Self {
<i32>::MAX
} else if self < <i32>::MIN as Self { <i32>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i32> {
if self > <i32>::MAX as Self || self < <i32>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i128>() >= size_of::<i16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i128 to i16 because i128 is smaller than i16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i16> for i128 {
#[inline]
fn internal_truncate(self) -> i16 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i16 {
if self > <i16>::MAX as Self {
<i16>::MAX
} else if self < <i16>::MIN as Self { <i16>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i16> {
if self > <i16>::MAX as Self || self < <i16>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<i128>() >= size_of::<i8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate i128 to i8 because i128 is smaller than i8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i8> for i128 {
#[inline]
fn internal_truncate(self) -> i8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i8 {
if self > <i8>::MAX as Self {
<i8>::MAX
} else if self < <i8>::MIN as Self { <i8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i8> {
if self > <i8>::MAX as Self || self < <i8>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<isize>() >= size_of::<isize>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate isize to isize because isize is smaller than isize"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<isize> for isize {
#[inline]
fn internal_truncate(self) -> isize { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> isize {
if self > <isize>::MAX as Self {
<isize>::MAX
} else if self < <isize>::MIN as Self {
<isize>::MIN
} else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<isize> {
if self > <isize>::MAX as Self || self < <isize>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<isize>() >= size_of::<i16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate isize to i16 because isize is smaller than i16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i16> for isize {
#[inline]
fn internal_truncate(self) -> i16 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i16 {
if self > <i16>::MAX as Self {
<i16>::MAX
} else if self < <i16>::MIN as Self { <i16>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i16> {
if self > <i16>::MAX as Self || self < <i16>::MIN as Self {
None
} else { Some(self as _) }
}
}
const _: () =
if !(size_of::<isize>() >= size_of::<i8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot truncate isize to i8 because isize is smaller than i8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl TruncateTarget<i8> for isize {
#[inline]
fn internal_truncate(self) -> i8 { self as _ }
#[inline]
fn internal_saturating_truncate(self) -> i8 {
if self > <i8>::MAX as Self {
<i8>::MAX
} else if self < <i8>::MIN as Self { <i8>::MIN } else { self as _ }
}
#[inline]
fn internal_checked_truncate(self) -> Option<i8> {
if self > <i8>::MAX as Self || self < <i8>::MIN as Self {
None
} else { Some(self as _) }
}
}impl_truncate! {
100 u8 => u8;
101 u16 => u16, u8;
102 u32 => u32, u16, u8;
103 u64 => u64, u32, u16, u8;
104 u128 => u128, u64, u32, u16, u8;
105 usize => usize, u16, u8;
106
107 i8 => i8;
108 i16 => i16, i8;
109 i32 => i32, i16, i8;
110 i64 => i64, i32, i16, i8;
111 i128 => i128, i64, i32, i16, i8;
112 isize => isize, i16, i8;
113}
114
115const _: () =
if !(size_of::<u8>() <= size_of::<u8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u8 to u8 because u8 is larger than u8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u8> for u8 {
fn internal_widen(self) -> u8 { self as _ }
}
const _: () =
if !(size_of::<u8>() <= size_of::<u16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u8 to u16 because u8 is larger than u16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u16> for u8 {
fn internal_widen(self) -> u16 { self as _ }
}
const _: () =
if !(size_of::<u8>() <= size_of::<u32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u8 to u32 because u8 is larger than u32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u32> for u8 {
fn internal_widen(self) -> u32 { self as _ }
}
const _: () =
if !(size_of::<u8>() <= size_of::<u64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u8 to u64 because u8 is larger than u64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u64> for u8 {
fn internal_widen(self) -> u64 { self as _ }
}
const _: () =
if !(size_of::<u8>() <= size_of::<u128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u8 to u128 because u8 is larger than u128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u128> for u8 {
fn internal_widen(self) -> u128 { self as _ }
}
const _: () =
if !(size_of::<u8>() <= size_of::<usize>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u8 to usize because u8 is larger than usize"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<usize> for u8 {
fn internal_widen(self) -> usize { self as _ }
}
const _: () =
if !(size_of::<u16>() <= size_of::<u16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u16 to u16 because u16 is larger than u16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u16> for u16 {
fn internal_widen(self) -> u16 { self as _ }
}
const _: () =
if !(size_of::<u16>() <= size_of::<u32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u16 to u32 because u16 is larger than u32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u32> for u16 {
fn internal_widen(self) -> u32 { self as _ }
}
const _: () =
if !(size_of::<u16>() <= size_of::<u64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u16 to u64 because u16 is larger than u64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u64> for u16 {
fn internal_widen(self) -> u64 { self as _ }
}
const _: () =
if !(size_of::<u16>() <= size_of::<u128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u16 to u128 because u16 is larger than u128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u128> for u16 {
fn internal_widen(self) -> u128 { self as _ }
}
const _: () =
if !(size_of::<u16>() <= size_of::<usize>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u16 to usize because u16 is larger than usize"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<usize> for u16 {
fn internal_widen(self) -> usize { self as _ }
}
const _: () =
if !(size_of::<u32>() <= size_of::<u32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u32 to u32 because u32 is larger than u32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u32> for u32 {
fn internal_widen(self) -> u32 { self as _ }
}
const _: () =
if !(size_of::<u32>() <= size_of::<u64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u32 to u64 because u32 is larger than u64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u64> for u32 {
fn internal_widen(self) -> u64 { self as _ }
}
const _: () =
if !(size_of::<u32>() <= size_of::<u128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u32 to u128 because u32 is larger than u128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u128> for u32 {
fn internal_widen(self) -> u128 { self as _ }
}
const _: () =
if !(size_of::<u64>() <= size_of::<u64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u64 to u64 because u64 is larger than u64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u64> for u64 {
fn internal_widen(self) -> u64 { self as _ }
}
const _: () =
if !(size_of::<u64>() <= size_of::<u128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u64 to u128 because u64 is larger than u128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u128> for u64 {
fn internal_widen(self) -> u128 { self as _ }
}
const _: () =
if !(size_of::<u128>() <= size_of::<u128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen u128 to u128 because u128 is larger than u128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<u128> for u128 {
fn internal_widen(self) -> u128 { self as _ }
}
const _: () =
if !(size_of::<usize>() <= size_of::<usize>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen usize to usize because usize is larger than usize"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<usize> for usize {
fn internal_widen(self) -> usize { self as _ }
}
const _: () =
if !(size_of::<i8>() <= size_of::<i8>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i8 to i8 because i8 is larger than i8"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i8> for i8 {
fn internal_widen(self) -> i8 { self as _ }
}
const _: () =
if !(size_of::<i8>() <= size_of::<i16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i8 to i16 because i8 is larger than i16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i16> for i8 {
fn internal_widen(self) -> i16 { self as _ }
}
const _: () =
if !(size_of::<i8>() <= size_of::<i32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i8 to i32 because i8 is larger than i32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i32> for i8 {
fn internal_widen(self) -> i32 { self as _ }
}
const _: () =
if !(size_of::<i8>() <= size_of::<i64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i8 to i64 because i8 is larger than i64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i64> for i8 {
fn internal_widen(self) -> i64 { self as _ }
}
const _: () =
if !(size_of::<i8>() <= size_of::<i128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i8 to i128 because i8 is larger than i128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i128> for i8 {
fn internal_widen(self) -> i128 { self as _ }
}
const _: () =
if !(size_of::<i8>() <= size_of::<isize>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i8 to isize because i8 is larger than isize"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<isize> for i8 {
fn internal_widen(self) -> isize { self as _ }
}
const _: () =
if !(size_of::<i16>() <= size_of::<i16>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i16 to i16 because i16 is larger than i16"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i16> for i16 {
fn internal_widen(self) -> i16 { self as _ }
}
const _: () =
if !(size_of::<i16>() <= size_of::<i32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i16 to i32 because i16 is larger than i32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i32> for i16 {
fn internal_widen(self) -> i32 { self as _ }
}
const _: () =
if !(size_of::<i16>() <= size_of::<i64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i16 to i64 because i16 is larger than i64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i64> for i16 {
fn internal_widen(self) -> i64 { self as _ }
}
const _: () =
if !(size_of::<i16>() <= size_of::<i128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i16 to i128 because i16 is larger than i128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i128> for i16 {
fn internal_widen(self) -> i128 { self as _ }
}
const _: () =
if !(size_of::<i16>() <= size_of::<isize>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i16 to isize because i16 is larger than isize"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<isize> for i16 {
fn internal_widen(self) -> isize { self as _ }
}
const _: () =
if !(size_of::<i32>() <= size_of::<i32>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i32 to i32 because i32 is larger than i32"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i32> for i32 {
fn internal_widen(self) -> i32 { self as _ }
}
const _: () =
if !(size_of::<i32>() <= size_of::<i64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i32 to i64 because i32 is larger than i64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i64> for i32 {
fn internal_widen(self) -> i64 { self as _ }
}
const _: () =
if !(size_of::<i32>() <= size_of::<i128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i32 to i128 because i32 is larger than i128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i128> for i32 {
fn internal_widen(self) -> i128 { self as _ }
}
const _: () =
if !(size_of::<i64>() <= size_of::<i64>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i64 to i64 because i64 is larger than i64"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i64> for i64 {
fn internal_widen(self) -> i64 { self as _ }
}
const _: () =
if !(size_of::<i64>() <= size_of::<i128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i64 to i128 because i64 is larger than i128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i128> for i64 {
fn internal_widen(self) -> i128 { self as _ }
}
const _: () =
if !(size_of::<i128>() <= size_of::<i128>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen i128 to i128 because i128 is larger than i128"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<i128> for i128 {
fn internal_widen(self) -> i128 { self as _ }
}
const _: () =
if !(size_of::<isize>() <= size_of::<isize>()) {
{
crate::panicking::panic_fmt(format_args!("cannot widen isize to isize because isize is larger than isize"));
}
};
#[unstable(feature = "num_internals", reason =
"internal implementation detail", issue = "none")]
#[rustc_const_unstable(feature = "integer_widen_truncate", issue = "154330")]
const impl WidenTarget<isize> for isize {
fn internal_widen(self) -> isize { self as _ }
}impl_widen! {
116 u8 => u8, u16, u32, u64, u128, usize;
117 u16 => u16, u32, u64, u128, usize;
118 u32 => u32, u64, u128;
119 u64 => u64, u128;
120 u128 => u128;
121 usize => usize;
122
123 i8 => i8, i16, i32, i64, i128, isize;
124 i16 => i16, i32, i64, i128, isize;
125 i32 => i32, i64, i128;
126 i64 => i64, i128;
127 i128 => i128;
128 isize => isize;
129}