Skip to content

Add missing Debug derive to vec::IntoIter #580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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 @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Add missing `Debug` derive to `vec::IntoIter`.
- `bytes::BufMut` is now implemented on `VecInner`.
- Removed generic from `history_buf::OldestOrdered`.
- Made `LenType` opt-in.
Expand Down
25 changes: 25 additions & 0 deletions src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,31 @@ where
}
}

impl<T, LenT: LenType, const N: usize> core::fmt::Debug for IntoIter<T, N, LenT>
where
T: core::fmt::Debug,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let s = if self.next < self.vec.len {
unsafe {
slice::from_raw_parts(
self.vec
.buffer
.buffer
.as_ptr()
.cast::<T>()
.add(self.next.into_usize()),
(self.vec.len - self.next).into_usize(),
)
}
} else {
&[]
};

write!(f, "{:?}", s)
}
}

impl<T, LenT: LenType, const N: usize> Drop for IntoIter<T, N, LenT> {
fn drop(&mut self) {
unsafe {
Expand Down