-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add as_slice() to slice::IterMut and vec::Drain #58924
Conversation
In indexmap-rs/indexmap#88, we found that there was no easy way to implement `Debug` for our `IterMut` and `Drain` iterators. Those are built on `slice::IterMut` and `vec::Drain`, which implement `Debug` themselves, but have no other way to access their data. With a new `as_slice()` method, we can read the data and customize its presentation.
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
FWIW, these could both support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks good to me. Please open a tracking issue and add the number.
Co-Authored-By: cuviper <cuviper@gmail.com>
@bors r+ |
📌 Commit e478cad has been approved by |
Add as_slice() to slice::IterMut and vec::Drain In indexmap-rs/indexmap#88, we found that there was no easy way to implement `Debug` for our `IterMut` and `Drain` iterators. Those are built on `slice::IterMut` and `vec::Drain`, which implement `Debug` themselves, but have no other way to access their data. With a new `as_slice()` method, we can read the data and customize its presentation.
Add as_slice() to slice::IterMut and vec::Drain In indexmap-rs/indexmap#88, we found that there was no easy way to implement `Debug` for our `IterMut` and `Drain` iterators. Those are built on `slice::IterMut` and `vec::Drain`, which implement `Debug` themselves, but have no other way to access their data. With a new `as_slice()` method, we can read the data and customize its presentation.
Add as_slice() to slice::IterMut and vec::Drain In indexmap-rs/indexmap#88, we found that there was no easy way to implement `Debug` for our `IterMut` and `Drain` iterators. Those are built on `slice::IterMut` and `vec::Drain`, which implement `Debug` themselves, but have no other way to access their data. With a new `as_slice()` method, we can read the data and customize its presentation.
Rollup of 13 pull requests Successful merges: - #58518 (Use early unwraps instead of bubbling up errors just to unwrap in the end) - #58626 (rustdoc: add option to calculate "documentation coverage") - #58629 (rust-lldb: fix crash when printing empty string) - #58660 (MaybeUninit: add read_initialized, add examples) - #58670 (fixes #52482) - #58676 (look for python2 symlinks before bootstrap python) - #58679 (Refactor passes and pass execution to be more parallel) - #58750 (Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const) - #58762 (Mention `unwind(aborts)` in diagnostics for `#[unwind]`) - #58924 (Add as_slice() to slice::IterMut and vec::Drain) - #58990 (Actually publish miri in the manifest) - #59018 (std: Delete a by-definition spuriously failing test) - #59045 (Expose new_sub_parser_from_file) Failed merges: r? @ghost
FYI @rust-lang/libs: two unstable methods:
impl<'a, T> slice::IterMut<'a, T> {
pub fn as_slice(&self) -> &[T];
}
impl<'a, T> vec::Drain<'a, T> {
pub fn as_slice(&self) -> &[T];
} Tracking issue: #58957. |
In indexmap-rs/indexmap#88, we found that there was no easy way to implement
Debug
for ourIterMut
andDrain
iterators. Those are built onslice::IterMut
andvec::Drain
, which implementDebug
themselves,but have no other way to access their data. With a new
as_slice()
method, we can read the data and customize its presentation.