Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/ringbuffer_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ pub trait RingBufferRead<T>: RingBuffer<T> + IntoIterator<Item = T> {

/// 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.
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions src/with_alloc/alloc_ringbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ impl<T, SIZE: RingbufferSize> RingBufferRead<T> for AllocRingBuffer<T, SIZE> {
unsafe { Some(ptr::read(res)) }
}
}

impl_ringbuffer_read!();
}

impl<T, SIZE: RingbufferSize> Extend<T> for AllocRingBuffer<T, SIZE> {
Expand Down
2 changes: 0 additions & 2 deletions src/with_alloc/vecdeque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ impl<T> RingBufferRead<T> for GrowableAllocRingBuffer<T> {
fn dequeue(&mut self) -> Option<T> {
self.pop_front()
}

impl_ringbuffer_read!();
}

impl<T> RingBufferWrite<T> for GrowableAllocRingBuffer<T> {
Expand Down
2 changes: 0 additions & 2 deletions src/with_const_generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ impl<T, const CAP: usize> RingBufferRead<T> for ConstGenericRingBuffer<T, CAP> {
unsafe { Some(res.assume_init()) }
}
}

impl_ringbuffer_read!();
}

impl<T, const CAP: usize> Extend<T> for ConstGenericRingBuffer<T, CAP> {
Expand Down