diff --git a/CHANGELOG.md b/CHANGELOG.md index e53084b14e..f46f74018a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed - `bytes::BufMut` is now implemented on `VecInner`. +- Removed generic from `history_buf::OldestOrdered`. ### Fixed diff --git a/src/history_buf.rs b/src/history_buf.rs index ab251c0d39..f1a30d573d 100644 --- a/src/history_buf.rs +++ b/src/history_buf.rs @@ -520,10 +520,9 @@ impl + ?Sized> HistoryBufInner { /// assert_eq!(x, y) /// } /// ``` - pub fn oldest_ordered(&self) -> OldestOrderedInner<'_, T, S> { + pub fn oldest_ordered(&self) -> OldestOrdered<'_, T> { let (old, new) = self.as_slices(); - OldestOrderedInner { - phantom: PhantomData, + OldestOrdered { inner: old.iter().chain(new), } } @@ -612,62 +611,21 @@ where } } -/// Base struct for [`OldestOrdered`] and [`OldestOrderedView`], generic over the [`HistoryBufStorage`]. -/// -/// In most cases you should use [`OldestOrdered`] or [`OldestOrderedView`] directly. Only use this -/// struct if you want to write code that's generic over both. -pub struct OldestOrderedInner<'a, T, S: HistoryBufStorage + ?Sized> { - phantom: PhantomData, - inner: core::iter::Chain, core::slice::Iter<'a, T>>, -} - /// Double ended iterator on the underlying buffer ordered from the oldest data /// to the newest. -/// -/// This type exists for backwards compatibility. It is always better to convert it to an [`OldestOrderedView`] with [`into_view`](OldestOrdered::into_view) -pub type OldestOrdered<'a, T, const N: usize> = - OldestOrderedInner<'a, T, OwnedHistoryBufStorage>; - -/// Double ended iterator on the underlying buffer ordered from the oldest data -/// to the newest -pub type OldestOrderedView<'a, T> = OldestOrderedInner<'a, T, ViewHistoryBufStorage>; - -impl<'a, T, const N: usize> OldestOrdered<'a, T, N> { - /// Remove the `N` const-generic parameter from the iterator - /// - /// For the opposite operation, see [`into_legacy_iter`](OldestOrderedView::into_legacy_iter) - pub fn into_view(self) -> OldestOrderedView<'a, T> { - OldestOrderedView { - phantom: PhantomData, - inner: self.inner, - } - } -} - -impl<'a, T> OldestOrderedView<'a, T> { - /// Add back the `N` const-generic parameter to use it with APIs expecting the legacy type - /// - /// You probably do not need this - /// - /// For the opposite operation, see [`into_view`](OldestOrdered::into_view) - pub fn into_legacy_iter(self) -> OldestOrdered<'a, T, N> { - OldestOrdered { - phantom: PhantomData, - inner: self.inner, - } - } +pub struct OldestOrdered<'a, T> { + inner: core::iter::Chain, core::slice::Iter<'a, T>>, } -impl + ?Sized> Clone for OldestOrderedInner<'_, T, S> { +impl Clone for OldestOrdered<'_, T> { fn clone(&self) -> Self { Self { - phantom: PhantomData, inner: self.inner.clone(), } } } -impl<'a, T, S: HistoryBufStorage + ?Sized> Iterator for OldestOrderedInner<'a, T, S> { +impl<'a, T> Iterator for OldestOrdered<'a, T> { type Item = &'a T; fn next(&mut self) -> Option<&'a T> { @@ -679,7 +637,7 @@ impl<'a, T, S: HistoryBufStorage + ?Sized> Iterator for OldestOrderedInner<'a } } -impl DoubleEndedIterator for OldestOrdered<'_, T, N> { +impl DoubleEndedIterator for OldestOrdered<'_, T> { fn next_back(&mut self) -> Option { self.inner.next_back() }