@@ -83,6 +83,17 @@ unsafe impl<T, const N: usize, const K: usize, const WN: usize, const WK: usize>
8383{
8484}
8585
86+ impl < T , const N : usize , const K : usize , const WN : usize , const WK : usize > Default
87+ for PoolStorageImpl < T , N , K , WN , WK >
88+ where
89+ [ AtomicU32 ; K ] : Sized ,
90+ [ AtomicU32 ; WK ] : Sized ,
91+ {
92+ fn default ( ) -> Self {
93+ Self :: new ( )
94+ }
95+ }
96+
8697impl < T , const N : usize , const K : usize , const WN : usize , const WK : usize >
8798 PoolStorageImpl < T , N , K , WN , WK >
8899where
@@ -178,10 +189,7 @@ impl<P: Pool> Box<P> {
178189 /// Returns an item from the data pool, if available.
179190 /// Returns None if the data pool is full.
180191 pub fn new ( item : P :: Item ) -> Option < Self > {
181- let p = match P :: get ( ) . alloc ( ) {
182- Some ( p) => p,
183- None => return None ,
184- } ;
192+ let p = P :: get ( ) . alloc ( ) ?;
185193 unsafe { p. as_ptr ( ) . write ( item) } ;
186194 Some ( Self { ptr : p } )
187195 }
@@ -203,6 +211,9 @@ impl<P: Pool> Box<P> {
203211 res
204212 }
205213
214+ /// # Safety
215+ ///
216+ /// The caller must ensure the pointer is valid and that it will live long enough.
206217 pub unsafe fn from_raw ( ptr : NonNull < P :: Item > ) -> Self {
207218 Self { ptr }
208219 }
0 commit comments