diff --git a/src/ringbuffer_trait.rs b/src/ringbuffer_trait.rs index 341247d..e6e21fa 100644 --- a/src/ringbuffer_trait.rs +++ b/src/ringbuffer_trait.rs @@ -71,7 +71,10 @@ pub trait RingBufferRead: RingBuffer + IntoIterator { /// dequeues the top item off the queue, but does not return it. Instead it is dropped. /// If the ringbuffer is empty, this function is a nop. - fn skip(&mut self); + #[inline] + fn skip(&mut self) { + let _ = self.dequeue(); + } /// Returns an iterator over the elements in the ringbuffer, /// dequeueing elements as they are iterated over. @@ -420,17 +423,6 @@ pub use iter::{ RingBufferDrainingIterator, RingBufferIntoIterator, RingBufferIterator, RingBufferMutIterator, }; -/// Implement various functions on implementors of [`RingBufferRead`]. -/// This is to avoid duplicate code. -macro_rules! impl_ringbuffer_read { - () => { - #[inline] - fn skip(&mut self) { - let _ = self.dequeue().map(drop); - } - }; -} - /// Implement various functions on implementors of [`RingBuffer`]. /// This is to avoid duplicate code. macro_rules! impl_ringbuffer { diff --git a/src/with_alloc/alloc_ringbuffer.rs b/src/with_alloc/alloc_ringbuffer.rs index 5929b7b..f3e5d82 100644 --- a/src/with_alloc/alloc_ringbuffer.rs +++ b/src/with_alloc/alloc_ringbuffer.rs @@ -270,8 +270,6 @@ impl RingBufferRead for AllocRingBuffer { unsafe { Some(ptr::read(res)) } } } - - impl_ringbuffer_read!(); } impl Extend for AllocRingBuffer { diff --git a/src/with_alloc/vecdeque.rs b/src/with_alloc/vecdeque.rs index fcdea6a..ba31737 100644 --- a/src/with_alloc/vecdeque.rs +++ b/src/with_alloc/vecdeque.rs @@ -165,8 +165,6 @@ impl RingBufferRead for GrowableAllocRingBuffer { fn dequeue(&mut self) -> Option { self.pop_front() } - - impl_ringbuffer_read!(); } impl RingBufferWrite for GrowableAllocRingBuffer { diff --git a/src/with_const_generics.rs b/src/with_const_generics.rs index 56e6cf8..f60b763 100644 --- a/src/with_const_generics.rs +++ b/src/with_const_generics.rs @@ -238,8 +238,6 @@ impl RingBufferRead for ConstGenericRingBuffer { unsafe { Some(res.assume_init()) } } } - - impl_ringbuffer_read!(); } impl Extend for ConstGenericRingBuffer {