Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Implement `defmt::Format` for `CapacityError`.
- Implement `TryFrom` for `Deque` from array.
- Switch from `serde` to `serde_core` for enabling faster compilations.
- Removed `impl Deref` for `HistoryBuf` to make accessing the raw backing array explicit (use `as_slice`).

## [v0.9.1] - 2025-08-19

Expand Down
18 changes: 4 additions & 14 deletions src/history_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
use core::fmt;
use core::marker::PhantomData;
use core::mem::MaybeUninit;
use core::ops::Deref;
use core::ptr;
use core::slice;

Expand Down Expand Up @@ -572,18 +571,10 @@ impl<T, S: HistoryBufStorage<T> + ?Sized> Drop for HistoryBufInner<T, S> {
}
}

impl<T, S: HistoryBufStorage<T> + ?Sized> Deref for HistoryBufInner<T, S> {
type Target = [T];

fn deref(&self) -> &[T] {
self.as_slice()
}
}

impl<T, S: HistoryBufStorage<T> + ?Sized> AsRef<[T]> for HistoryBufInner<T, S> {
#[inline]
fn as_ref(&self) -> &[T] {
self
self.as_slice()
}
}

Expand All @@ -592,7 +583,7 @@ where
T: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
<[T] as fmt::Debug>::fmt(self, f)
<[T] as fmt::Debug>::fmt(self.as_slice(), f)
}
}

Expand Down Expand Up @@ -660,7 +651,6 @@ mod tests {
let x: HistoryBuf<u8, 4> = HistoryBuf::new_with(1);
assert_eq!(x.len(), 4);
assert_eq!(x.as_slice(), [1; 4]);
assert_eq!(*x, [1; 4]);
assert!(x.is_full());

let x: HistoryBuf<u8, 4> = HistoryBuf::new();
Expand Down Expand Up @@ -910,8 +900,8 @@ mod tests {
x,
y,
"{:?} {:?}",
x.iter().collect::<Vec<_>>(),
y.iter().collect::<Vec<_>>()
x.as_slice().iter().collect::<Vec<_>>(),
y.as_slice().iter().collect::<Vec<_>>()
);
}
}
Expand Down