rustc_data_structures/
packed.rs1use std::cmp::Ordering;
2use std::fmt;
3
4use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
5
6use crate::stable_hasher::{HashStable, StableHasher};
7
8#[derive(#[automatically_derived]
impl ::core::marker::Copy for Pu128 { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Pu128 {
#[inline]
fn clone(&self) -> Pu128 {
let _: ::core::clone::AssertParamIsClone<u128>;
*self
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Pu128 {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Pu128",
&&{ self.0 })
}
}Debug, #[automatically_derived]
impl ::core::hash::Hash for Pu128 {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
::core::hash::Hash::hash(&{ self.0 }, state)
}
}Hash, #[automatically_derived]
impl ::core::cmp::PartialEq for Pu128 {
#[inline]
fn eq(&self, other: &Pu128) -> bool { ({ self.0 }) == ({ other.0 }) }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Pu128 {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<u128>;
}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialOrd for Pu128 {
#[inline]
fn partial_cmp(&self, other: &Pu128)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::cmp::PartialOrd::partial_cmp(&{ self.0 }, &{ other.0 })
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for Pu128 {
#[inline]
fn cmp(&self, other: &Pu128) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&{ self.0 }, &{ other.0 })
}
}Ord)]
11#[repr(packed(8))]
12pub struct Pu128(pub u128);
13
14impl Pu128 {
15 #[inline]
16 pub fn get(self) -> u128 {
17 self.0
18 }
19}
20
21impl From<Pu128> for u128 {
22 #[inline]
23 fn from(value: Pu128) -> Self {
24 value.get()
25 }
26}
27
28impl From<u128> for Pu128 {
29 #[inline]
30 fn from(value: u128) -> Self {
31 Self(value)
32 }
33}
34
35impl PartialEq<u128> for Pu128 {
36 #[inline]
37 fn eq(&self, other: &u128) -> bool {
38 ({ self.0 }) == *other
39 }
40}
41
42impl PartialOrd<u128> for Pu128 {
43 #[inline]
44 fn partial_cmp(&self, other: &u128) -> Option<Ordering> {
45 { self.0 }.partial_cmp(other)
46 }
47}
48
49impl fmt::Display for Pu128 {
50 #[inline]
51 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
52 { self.0 }.fmt(f)
53 }
54}
55
56impl fmt::UpperHex for Pu128 {
57 #[inline]
58 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
59 { self.0 }.fmt(f)
60 }
61}
62
63impl<CTX> HashStable<CTX> for Pu128 {
64 #[inline]
65 fn hash_stable(&self, ctx: &mut CTX, hasher: &mut StableHasher) {
66 { self.0 }.hash_stable(ctx, hasher)
67 }
68}
69
70impl<S: Encoder> Encodable<S> for Pu128 {
71 #[inline]
72 fn encode(&self, s: &mut S) {
73 { self.0 }.encode(s);
74 }
75}
76
77impl<D: Decoder> Decodable<D> for Pu128 {
78 #[inline]
79 fn decode(d: &mut D) -> Self {
80 Self(u128::decode(d))
81 }
82}