i256/uint/
casts.rs

1//! Casts between primitive and signed <-> unsigned big integers.
2
3#[rustfmt::skip]
4macro_rules! define {
5    (
6        signed_type => $s_t:ty,
7        bits => $bits:expr,
8        see_type => $see_t:ty,
9        kind => $kind:ident $(,)?
10    ) => {
11        $crate::shared::casts::define!(
12            unsigned_type => Self,
13            signed_type => $s_t,
14            bits => $bits,
15            kind => $kind,
16        );
17
18        /// Returns the bit pattern of `self` reinterpreted as a signed integer of
19        /// the same size.
20        ///
21        /// This produces the same result as an `as` cast, but ensures that the
22        /// bit-width remains the same.
23        ///
24        #[doc = $crate::shared::docs::primitive_doc!($see_t, cast_signed)]
25        #[inline(always)]
26        #[must_use = $crate::shared::docs::must_use_copy_doc!()]
27        pub const fn cast_signed(self) -> $s_t {
28            self.as_signed()
29        }
30    };
31}
32
33pub(crate) use define;