@@ -104,7 +104,9 @@ impl<T, const N: usize> Channel<T, N> {
104
104
105
105
/// Clear any remaining items from this `Channel`.
106
106
pub fn clear ( & mut self ) {
107
- for _ in self . queued_items ( ) { }
107
+ for item in self . queued_items ( ) {
108
+ drop ( item) ;
109
+ }
108
110
}
109
111
110
112
/// Return an iterator over the still-queued items, removing them
@@ -131,7 +133,7 @@ impl<T, const N: usize> Channel<T, N> {
131
133
// NOTE: do not `return_free_slot`, as we have mutable
132
134
// access to this `Channel` and no `Receiver` or `Sender`
133
135
// exist.
134
- assert ! ( !self . inner. freeq. as_mut( ) . is_full( ) ) ;
136
+ debug_assert ! ( !self . inner. freeq. as_mut( ) . is_full( ) ) ;
135
137
unsafe {
136
138
// SAFETY: `freeq` is not ful.
137
139
self . inner . freeq . as_mut ( ) . push_back_unchecked ( slot) ;
@@ -163,11 +165,10 @@ impl<T, const N: usize> Channel<T, N> {
163
165
164
166
// Fill free queue
165
167
for idx in 0 ..N as u8 {
166
- // NOTE(assert): `split`-ing does not put `freeq` into a known-empty
167
- // state, so `debug_assert` is not good enough.
168
- assert ! ( !freeq. is_full( ) ) ;
168
+ debug_assert ! ( !freeq. is_full( ) ) ;
169
169
170
- // SAFETY: This safe as the loop goes from 0 to the capacity of the underlying queue.
170
+ // SAFETY: This safe as the loop goes from 0 to the capacity of the underlying queue,
171
+ // and the queue is cleared beforehand.
171
172
unsafe {
172
173
freeq. push_back_unchecked ( idx) ;
173
174
}
@@ -207,7 +208,7 @@ impl<T, const N: usize> Channel<T, N> {
207
208
// SAFETY: `self.freeq` is not called recursively.
208
209
unsafe {
209
210
self . freeq ( cs, |freeq| {
210
- assert ! ( !freeq. is_full( ) ) ;
211
+ debug_assert ! ( !freeq. is_full( ) ) ;
211
212
// SAFETY: `freeq` is not full.
212
213
freeq. push_back_unchecked ( slot) ;
213
214
} ) ;
@@ -385,7 +386,7 @@ impl<T, const N: usize> Sender<'_, T, N> {
385
386
// SAFETY: `self.0.readyq` is not called recursively.
386
387
unsafe {
387
388
self . 0 . readyq ( cs, |readyq| {
388
- assert ! ( !readyq. is_full( ) ) ;
389
+ debug_assert ! ( !readyq. is_full( ) ) ;
389
390
// SAFETY: ready is not full.
390
391
readyq. push_back_unchecked ( idx) ;
391
392
} ) ;
@@ -519,7 +520,7 @@ impl<T, const N: usize> Sender<'_, T, N> {
519
520
// SAFETY: `self.0.freeq` is not called recursively.
520
521
unsafe {
521
522
self . 0 . freeq ( cs, |freeq| {
522
- assert ! ( !freeq. is_empty( ) ) ;
523
+ debug_assert ! ( !freeq. is_empty( ) ) ;
523
524
// SAFETY: `freeq` is non-empty
524
525
let slot = freeq. pop_back_unchecked ( ) ;
525
526
Poll :: Ready ( Ok ( slot) )
0 commit comments