-
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
Implement Debug
for std::path::{Components,Iter}
.
#36101
Conversation
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
let components = self.as_path() | ||
.components() | ||
.collect::<Vec<_>>(); |
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.
It's a shame to have to allocate on debug. You should be able to do this using debug_list
and a helper struct.
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.
Yeah, I can switch this to debug_list
to avoid the allocation, though we lose the "Components" title. I wonder if there is value in adding a debug_iter
that offers name
and iterator
params.
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.
Make a helper struct that implements debug and outputs [...]
. That is,
f.debug_tuple("Components").field(&DebugHelper(self)).finish();
where DebugHelper
implements Debug
.
Thanks @frewsxcv! I wonder if perhaps the same implementation should be used for the other iterators in this module? |
8ce02e1
to
8cc3070
Compare
Debug
for std::path::Components
.Debug
for std::path::{Components,Iter}
.
Latest commits no longer allocate |
8cc3070
to
b8ebf77
Compare
@@ -639,6 +639,25 @@ pub struct Iter<'a> { | |||
inner: Components<'a>, | |||
} | |||
|
|||
#[stable(feature = "path_components_debug", since = "")] |
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.
This since should be 1.13.0 I believe
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.
Addressed in the latest force push.
b8ebf77
to
e118d4c
Compare
@bors rollup |
…lexcrichton Implement `Debug` for `std::path::{Components,Iter}`. None
@bors r- I'm seeing this failure on build_bot (auto-win-msvc-64-opt-rustbuild), and it seems related:
If that's not related I can re-approve. |
e118d4c
to
268b3f5
Compare
More info:
I changed that test to only run on |
@bors: r+ |
📌 Commit 268b3f5 has been approved by |
…lexcrichton Implement `Debug` for `std::path::{Components,Iter}`. None
…lexcrichton Implement `Debug` for `std::path::{Components,Iter}`. None
No description provided.