@@ -12,6 +12,7 @@ use alloc::{
1212} ;
1313use core:: {
1414 cell:: UnsafeCell ,
15+ fmt,
1516 marker:: PhantomData ,
1617 mem:: { ManuallyDrop , MaybeUninit } ,
1718 ops:: { Deref , DerefMut } ,
@@ -92,6 +93,14 @@ pub struct VecBelt<T> {
9293 tail : UnsafeCell < NonNull < Fragment < T > > > ,
9394}
9495
96+ impl < T > fmt:: Debug for VecBelt < T > {
97+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
98+ f. debug_struct ( core:: any:: type_name :: < T > ( ) )
99+ . field ( "len" , & self . len ( ) )
100+ . finish_non_exhaustive ( )
101+ }
102+ }
103+
95104/// # Safety
96105///
97106/// [`VecBelt<T>`] provides synchronization primitives that won't lead to data races.
@@ -121,26 +130,26 @@ impl<T> VecBelt<T> {
121130 /// Reads the length of the vector atomically. Prefer [`len_mut`](Self::len_mut) if possible.
122131 #[ inline]
123132 pub fn len ( & self ) -> usize {
124- self . len . load ( Relaxed )
133+ self . len . load ( Relaxed ) & MASK
125134 }
126135
127136 /// Tests whether the vector is empty atomically. Prefer [`is_empty_mut`](Self::is_empty_mut) if
128137 /// possible.
129138 #[ inline]
130139 pub fn is_empty ( & self ) -> bool {
131- self . len . load ( Relaxed ) == 0
140+ self . len . load ( Relaxed ) & MASK == 0
132141 }
133142
134143 /// Reads the length of the vector non-atomically via `&mut self`.
135144 #[ inline]
136145 pub fn len_mut ( & mut self ) -> usize {
137- * self . len . get_mut ( )
146+ * self . len . get_mut ( ) & MASK
138147 }
139148
140149 /// Tests whether the vector is empty non-atomically via `&mut self`.
141150 #[ inline]
142151 pub fn is_empty_mut ( & mut self ) -> bool {
143- * self . len . get_mut ( ) == 0
152+ * self . len . get_mut ( ) & MASK == 0
144153 }
145154
146155 /// Extends the vector by `additional` elements, returning an uninitialized slice to it and the
0 commit comments