Skip to content
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

Merged
merged 2 commits into from Aug 31, 2016

Conversation

@frewsxcv
Copy link
Member

frewsxcv commented Aug 29, 2016

No description provided.

fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let components = self.as_path()
.components()
.collect::<Vec<_>>();

This comment has been minimized.

Copy link
@Stebalien

Stebalien Aug 29, 2016

Contributor

It's a shame to have to allocate on debug. You should be able to do this using debug_list and a helper struct.

This comment has been minimized.

Copy link
@frewsxcv

frewsxcv Aug 29, 2016

Author Member

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.

This comment has been minimized.

Copy link
@Stebalien

Stebalien Aug 29, 2016

Contributor

Make a helper struct that implements debug and outputs [...]. That is,

f.debug_tuple("Components").field(&DebugHelper(self)).finish();

where DebugHelper implements Debug.

@alexcrichton alexcrichton added the T-libs label Aug 29, 2016
@alexcrichton alexcrichton self-assigned this Aug 29, 2016
@alexcrichton
Copy link
Member

alexcrichton commented Aug 29, 2016

Thanks @frewsxcv! I wonder if perhaps the same implementation should be used for the other iterators in this module?

@frewsxcv frewsxcv force-pushed the frewsxcv:debug-path-components branch from 8ce02e1 to 8cc3070 Aug 30, 2016
@frewsxcv frewsxcv changed the title Implement `Debug` for `std::path::Components`. Implement `Debug` for `std::path::{Components,Iter}`. Aug 30, 2016
@frewsxcv
Copy link
Member Author

frewsxcv commented Aug 30, 2016

Latest commits no longer allocate Vecs. I also implemented Debug for std::path::Iter.

@frewsxcv frewsxcv force-pushed the frewsxcv:debug-path-components branch from 8cc3070 to b8ebf77 Aug 30, 2016
@@ -639,6 +639,25 @@ pub struct Iter<'a> {
inner: Components<'a>,
}

#[stable(feature = "path_components_debug", since = "")]

This comment has been minimized.

Copy link
@alexcrichton

alexcrichton Aug 30, 2016

Member

This since should be 1.13.0 I believe

This comment has been minimized.

Copy link
@frewsxcv

frewsxcv Aug 30, 2016

Author Member

Addressed in the latest force push.

@frewsxcv frewsxcv force-pushed the frewsxcv:debug-path-components branch from b8ebf77 to e118d4c Aug 30, 2016
@alexcrichton
Copy link
Member

alexcrichton commented Aug 30, 2016

@jonathandturner
Copy link
Contributor

jonathandturner commented Aug 30, 2016

@bors rollup

jonathandturner added a commit to jonathandturner/rust that referenced this pull request Aug 30, 2016
…lexcrichton

Implement `Debug` for `std::path::{Components,Iter}`.

None
bors added a commit that referenced this pull request Aug 30, 2016
Rollup of 11 pull requests

- Successful merges: #35758, #35793, #36085, #36089, #36101, #36130, #36134, #36135, #36136, #36140, #36141
- Failed merges:
bors added a commit that referenced this pull request Aug 30, 2016
Rollup of 11 pull requests

- Successful merges: #35758, #35793, #36085, #36089, #36101, #36130, #36134, #36135, #36136, #36140, #36141
- Failed merges:
bors added a commit that referenced this pull request Aug 30, 2016
Rollup of 11 pull requests

- Successful merges: #35758, #35793, #36085, #36089, #36101, #36130, #36134, #36135, #36136, #36140, #36141
- Failed merges:
@jonathandturner
Copy link
Contributor

jonathandturner commented Aug 30, 2016

@bors r-

I'm seeing this failure on build_bot (auto-win-msvc-64-opt-rustbuild), and it seems related:

failures:
    path::tests::test_iter_debug

test result: FAILED. 736 passed; 1 failed; 4 ignored; 0 measured

If that's not related I can re-approve.

@frewsxcv frewsxcv force-pushed the frewsxcv:debug-path-components branch from e118d4c to 268b3f5 Aug 30, 2016
@frewsxcv
Copy link
Member Author

frewsxcv commented Aug 30, 2016

More info:

thread '<unnamed>' panicked at 'assertion failed: `(left == right)` (left: `"Iter([\"/\", \"tmp\"])"`, right: `"Iter([\"\\\\\", \"tmp\"])"`)', C:\bot\slave\auto-win-msvc-64-opt-rustbuild\build\src\libstd\path.rs:3554

I changed that test to only run on unix now.

@alexcrichton
Copy link
Member

alexcrichton commented Aug 31, 2016

@bors: r+

@bors
Copy link
Contributor

bors commented Aug 31, 2016

📌 Commit 268b3f5 has been approved by alexcrichton

jonathandturner added a commit to jonathandturner/rust that referenced this pull request Aug 31, 2016
…lexcrichton

Implement `Debug` for `std::path::{Components,Iter}`.

None
bors added a commit that referenced this pull request Aug 31, 2016
jonathandturner added a commit to jonathandturner/rust that referenced this pull request Aug 31, 2016
…lexcrichton

Implement `Debug` for `std::path::{Components,Iter}`.

None
jonathandturner added a commit to jonathandturner/rust that referenced this pull request Aug 31, 2016
…lexcrichton

Implement `Debug` for `std::path::{Components,Iter}`.

None
bors added a commit that referenced this pull request Aug 31, 2016
@bors bors merged commit 268b3f5 into rust-lang:master Aug 31, 2016
1 check failed
1 check failed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
@frewsxcv frewsxcv deleted the frewsxcv:debug-path-components branch Aug 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.