Debian Codegraph @

src/count.rs

raw symbols SCIP
1 //! Counter-width abstraction for histogram bucket counts.
2 //!
3 //! The [`Count`] trait abstracts over the bucket counter width. It is
4 //! implemented for `u32` and `u64`. The trait is sealed: it cannot be
5 //! implemented outside this crate.
6 //!
7 //! [`AtomicCount`] is the matching atomic-primitive trait, mapped via the
8 //! [`Count::Atomic`] associated type. It is implemented for `AtomicU32`
9 //! (paired with `u32`) and `AtomicU64` (paired with `u64`).
10
11 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/::atomicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/::{AtomicU32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU32#, AtomicU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU64#, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#};
12
13 mod privaterust-analyzer cargo histogram 1.5.0 count/private/ {
14 pub trait Sealedrust-analyzer cargo histogram 1.5.0 count/private/Sealed# {}
15 }
16
17 /// A counter type usable for histogram bucket counts.
18 ///
19 /// Sealed: implemented only for `u32` and `u64` inside this crate.
20 pub trait Countrust-analyzer cargo histogram 1.5.0 count/Count#: privaterust-analyzer cargo histogram 1.5.0 count/private/::Sealedrust-analyzer cargo histogram 1.5.0 count/private/Sealed# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq# + Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# + stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# + 'static {
21 /// The atomic-primitive counterpart used by `AtomicHistogram<Self>`.
22 type Atomicrust-analyzer cargo histogram 1.5.0 count/Count#Atomic#: AtomicCountrust-analyzer cargo histogram 1.5.0 count/AtomicCount#<Valuerust-analyzer cargo histogram 1.5.0 count/AtomicCount#Value# = Self>;
23
24 /// The additive identity for this counter type.
25 const ZEROrust-analyzer cargo histogram 1.5.0 count/Count#ZERO.: Self;
26 /// The multiplicative identity (used by `increment`).
27 const ONErust-analyzer cargo histogram 1.5.0 count/Count#ONE.: Self;
28
29 fn wrapping_addrust-analyzer cargo histogram 1.5.0 count/Count#wrapping_add().(self, other: Self) -> Self;
30 fn wrapping_subrust-analyzer cargo histogram 1.5.0 count/Count#wrapping_sub().(self, other: Self) -> Self;
31 fn checked_addrust-analyzer cargo histogram 1.5.0 count/Count#checked_add().(self, other: Self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Self>;
32 fn checked_subrust-analyzer cargo histogram 1.5.0 count/Count#checked_sub().(self, other: Self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Self>;
33
34 /// Widen to `u128` for partial-sum aggregation.
35 fn as_u128rust-analyzer cargo histogram 1.5.0 count/Count#as_u128().(self) -> u128;
36 /// Narrow from `u64`. Returns `None` if `v` exceeds the range of `Self`.
37 fn try_from_u64rust-analyzer cargo histogram 1.5.0 count/Count#try_from_u64().(v: u64) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Self>;
38 }
39
40 /// Atomic counterpart of a [`Count`] type.
41 ///
42 /// Sealed: implemented only for `AtomicU32` and `AtomicU64` inside this crate.
43 pub trait AtomicCountrust-analyzer cargo histogram 1.5.0 count/AtomicCount#: privaterust-analyzer cargo histogram 1.5.0 count/private/::Sealedrust-analyzer cargo histogram 1.5.0 count/private/Sealed# {
44 type Valuerust-analyzer cargo histogram 1.5.0 count/AtomicCount#Value#: Countrust-analyzer cargo histogram 1.5.0 count/Count#<Atomicrust-analyzer cargo histogram 1.5.0 count/Count#Atomic# = Self>;
45
46 fn newrust-analyzer cargo histogram 1.5.0 count/AtomicCount#new().(v: Self::Valuerust-analyzer cargo histogram 1.5.0 count/AtomicCount#Value#) -> Self;
47 fn load_relaxedrust-analyzer cargo histogram 1.5.0 count/AtomicCount#load_relaxed().(&self) -> Self::Valuerust-analyzer cargo histogram 1.5.0 count/AtomicCount#Value#;
48 fn store_relaxedrust-analyzer cargo histogram 1.5.0 count/AtomicCount#store_relaxed().(&self, v: Self::Valuerust-analyzer cargo histogram 1.5.0 count/AtomicCount#Value#);
49 fn fetch_add_relaxedrust-analyzer cargo histogram 1.5.0 count/AtomicCount#fetch_add_relaxed().(&self, v: Self::Valuerust-analyzer cargo histogram 1.5.0 count/AtomicCount#Value#);
50 fn swap_relaxedrust-analyzer cargo histogram 1.5.0 count/AtomicCount#swap_relaxed().(&self, v: Self::Valuerust-analyzer cargo histogram 1.5.0 count/AtomicCount#Value#) -> Self::Valuerust-analyzer cargo histogram 1.5.0 count/AtomicCount#Value#;
51 }
52
53 impl privaterust-analyzer cargo histogram 1.5.0 count/private/::Sealedrust-analyzer cargo histogram 1.5.0 count/private/Sealed# for u32 {}
54 impl privaterust-analyzer cargo histogram 1.5.0 count/private/::Sealedrust-analyzer cargo histogram 1.5.0 count/private/Sealed# for u64 {}
55 impl privaterust-analyzer cargo histogram 1.5.0 count/private/::Sealedrust-analyzer cargo histogram 1.5.0 count/private/Sealed# for AtomicU32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU32# {}
56 impl privaterust-analyzer cargo histogram 1.5.0 count/private/::Sealedrust-analyzer cargo histogram 1.5.0 count/private/Sealed# for AtomicU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU64# {}
57
58 impl Countrust-analyzer cargo histogram 1.5.0 count/Count# for u32 {
59 type Atomicrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]Atomic# = AtomicU32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU32#;
60 const ZEROrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]ZERO.: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count] = 0;
61 const ONErust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]ONE.: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count] = 1;
62
63 #[inline]
64 fn wrapping_addrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]wrapping_add().(self, other: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]) -> Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count] {
65 u32::wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_add().(self, other)
66 }
67 #[inline]
68 fn wrapping_subrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]wrapping_sub().(self, other: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]) -> Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count] {
69 u32::wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]wrapping_sub().(self, other)
70 }
71 #[inline]
72 fn checked_addrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]checked_add().(self, other: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]> {
73 u32::checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]checked_add().(self, other)
74 }
75 #[inline]
76 fn checked_subrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]checked_sub().(self, other: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]> {
77 u32::checked_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]checked_sub().(self, other)
78 }
79 #[inline]
80 fn as_u128rust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]as_u128().(self) -> u128 {
81 self as u128
82 }
83 #[inline]
84 fn try_from_u64rust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]try_from_u64().(v: u64) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]> {
85 u32::try_fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u32][`TryFrom<u64>`]try_from().(v).okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]ok().()
86 }
87 }
88
89 impl Countrust-analyzer cargo histogram 1.5.0 count/Count# for u64 {
90 type Atomicrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]Atomic# = AtomicU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU64#;
91 const ZEROrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]ZERO.: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count] = 0;
92 const ONErust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]ONE.: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count] = 1;
93
94 #[inline]
95 fn wrapping_addrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]wrapping_add().(self, other: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]) -> Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count] {
96 u64::wrapping_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]wrapping_add().(self, other)
97 }
98 #[inline]
99 fn wrapping_subrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]wrapping_sub().(self, other: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]) -> Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count] {
100 u64::wrapping_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]wrapping_sub().(self, other)
101 }
102 #[inline]
103 fn checked_addrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]checked_add().(self, other: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]> {
104 u64::checked_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]checked_add().(self, other)
105 }
106 #[inline]
107 fn checked_subrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]checked_sub().(self, other: Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]> {
108 u64::checked_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]checked_sub().(self, other)
109 }
110 #[inline]
111 fn as_u128rust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]as_u128().(self) -> u128 {
112 self as u128
113 }
114 #[inline]
115 fn try_from_u64rust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]try_from_u64().(v: u64) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]> {
116 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v)
117 }
118 }
119
120 impl AtomicCountrust-analyzer cargo histogram 1.5.0 count/AtomicCount# for AtomicU32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU32# {
121 type Valuerust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]Value# = u32;
122 #[inline]
123 fn newrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]new().(v: u32) -> Selfrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount] {
124 AtomicU32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU32#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU32]new().(v)
125 }
126 #[inline]
127 fn load_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]load_relaxed().(&self) -> u32 {
128 self.loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU32]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#)
129 }
130 #[inline]
131 fn store_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]store_relaxed().(&self, v: u32) {
132 self.storerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU32]store().(v, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#)
133 }
134 #[inline]
135 fn fetch_add_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]fetch_add_relaxed().(&self, v: u32) {
136 self.fetch_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU32]fetch_add().(v, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#);
137 }
138 #[inline]
139 fn swap_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]swap_relaxed().(&self, v: u32) -> u32 {
140 self.swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU32]swap().(v, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#)
141 }
142 }
143
144 impl AtomicCountrust-analyzer cargo histogram 1.5.0 count/AtomicCount# for AtomicU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU64# {
145 type Valuerust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU64][AtomicCount]Value# = u64;
146 #[inline]
147 fn newrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU64][AtomicCount]new().(v: u64) -> Selfrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU64][AtomicCount] {
148 AtomicU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU64#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU64]new().(v)
149 }
150 #[inline]
151 fn load_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU64][AtomicCount]load_relaxed().(&self) -> u64 {
152 self.loadrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU64]load().(Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#)
153 }
154 #[inline]
155 fn store_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU64][AtomicCount]store_relaxed().(&self, v: u64) {
156 self.storerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU64]store().(v, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#)
157 }
158 #[inline]
159 fn fetch_add_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU64][AtomicCount]fetch_add_relaxed().(&self, v: u64) {
160 self.fetch_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU64]fetch_add().(v, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#);
161 }
162 #[inline]
163 fn swap_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU64][AtomicCount]swap_relaxed().(&self, v: u64) -> u64 {
164 self.swaprust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/impl#[AtomicU64]swap().(v, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#::Relaxedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#Relaxed#)
165 }
166 }
167
168 #[cfg(test)]
169 mod testsrust-analyzer cargo histogram 1.5.0 count/tests/ {
170 use superrust-analyzer cargo histogram 1.5.0 count/::*;
171
172 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
173 fn u32_const_valuesrust-analyzer cargo histogram 1.5.0 count/tests/u32_const_values().() {
174 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::ZEROrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]ZERO., 0u32);
175 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::ONErust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]ONE., 1u32);
176 }
177
178 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
179 fn u64_const_valuesrust-analyzer cargo histogram 1.5.0 count/tests/u64_const_values().() {
180 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u64 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::ZEROrust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]ZERO., 0u64);
181 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u64 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::ONErust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]ONE., 1u64);
182 }
183
184 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
185 fn u32_wrapping_arithmeticrust-analyzer cargo histogram 1.5.0 count/tests/u32_wrapping_arithmetic().() {
186 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::wrapping_addrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]wrapping_add().(u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX., 1), 0);
187 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::wrapping_subrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]wrapping_sub().(0, 1), u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX.);
188 }
189
190 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
191 fn u32_checked_arithmeticrust-analyzer cargo histogram 1.5.0 count/tests/u32_checked_arithmetic().() {
192 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::checked_addrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]checked_add().(u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX., 1), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
193 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::checked_subrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]checked_sub().(0u32, 1), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
194 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::checked_addrust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]checked_add().(1u32, 1), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2));
195 }
196
197 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
198 fn try_from_u64_narrowingrust-analyzer cargo histogram 1.5.0 count/tests/try_from_u64_narrowing().() {
199 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::try_from_u64rust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]try_from_u64().(42), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(42u32));
200 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
201 <u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::try_from_u64rust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]try_from_u64().(u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX. as u64),
202 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX.)
203 );
204 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::try_from_u64rust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]try_from_u64().(u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX. as u64 +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). 1), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
205 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u64 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::try_from_u64rust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]try_from_u64().(u64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]MAX.), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(u64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]MAX.));
206 }
207
208 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
209 fn as_u128_wideningrust-analyzer cargo histogram 1.5.0 count/tests/as_u128_widening().() {
210 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u32 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::as_u128rust-analyzer cargo histogram 1.5.0 count/impl#[u32][Count]as_u128().(u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX.), u32::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]MAX. as u128);
211 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(<u64 as Countrust-analyzer cargo histogram 1.5.0 count/Count#>::as_u128rust-analyzer cargo histogram 1.5.0 count/impl#[u64][Count]as_u128().(u64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]MAX.), u64::MAXrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u64]MAX. as u128);
212 }
213
214 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
215 fn atomic_u32_basicrust-analyzer cargo histogram 1.5.0 count/tests/atomic_u32_basic().() {
216 let a = <AtomicU32rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU32# as AtomicCountrust-analyzer cargo histogram 1.5.0 count/AtomicCount#>::newrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]new().(0);
217 a.fetch_add_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]fetch_add_relaxed().(5);
218 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.load_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]load_relaxed().(), 5);
219 let prev = a.swap_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]swap_relaxed().(10);
220 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(prev, 5);
221 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.load_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU32][AtomicCount]load_relaxed().(), 10);
222 }
223
224 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
225 fn atomic_u64_basicrust-analyzer cargo histogram 1.5.0 count/tests/atomic_u64_basic().() {
226 let a = <AtomicU64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicU64# as AtomicCountrust-analyzer cargo histogram 1.5.0 count/AtomicCount#>::newrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU64][AtomicCount]new().(0);
227 a.fetch_add_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU64][AtomicCount]fetch_add_relaxed().(5);
228 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.load_relaxedrust-analyzer cargo histogram 1.5.0 count/impl#[AtomicU64][AtomicCount]load_relaxed().(), 5);
229 }
230 }