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

Merged
merged 2 commits into from Aug 31, 2016

Conversation

Projects
None yet
5 participants
@frewsxcv
Member

frewsxcv commented Aug 29, 2016

No description provided.

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

This comment has been minimized.

@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.

@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.

@frewsxcv

frewsxcv Aug 29, 2016

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.

@frewsxcv

frewsxcv Aug 29, 2016

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.

@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.

@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

This comment has been minimized.

Show comment
Hide comment
@alexcrichton

alexcrichton Aug 29, 2016

Member

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

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 changed the title from Implement `Debug` for `std::path::Components`. to Implement `Debug` for `std::path::{Components,Iter}`. Aug 30, 2016

@frewsxcv

This comment has been minimized.

Show comment
Hide comment
@frewsxcv

frewsxcv Aug 30, 2016

Member

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

Member

frewsxcv commented Aug 30, 2016

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

src/libstd/path.rs
@@ -639,6 +639,25 @@ pub struct Iter<'a> {
inner: Components<'a>,
}
+#[stable(feature = "path_components_debug", since = "")]

This comment has been minimized.

@alexcrichton

alexcrichton Aug 30, 2016

Member

This since should be 1.13.0 I believe

@alexcrichton

alexcrichton Aug 30, 2016

Member

This since should be 1.13.0 I believe

This comment has been minimized.

@frewsxcv

frewsxcv Aug 30, 2016

Member

Addressed in the latest force push.

@frewsxcv

frewsxcv Aug 30, 2016

Member

Addressed in the latest force push.

@alexcrichton

This comment has been minimized.

Show comment
Hide comment
Member

alexcrichton commented Aug 30, 2016

@jonathandturner

This comment has been minimized.

Show comment
Hide comment
@jonathandturner

jonathandturner Aug 30, 2016

Contributor

@bors rollup

Contributor

jonathandturner commented Aug 30, 2016

@bors rollup

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

Rollup merge of #36101 - frewsxcv:debug-path-components, r=alexcrichton
Implement `Debug` for `std::path::{Components,Iter}`.

None

bors added a commit that referenced this pull request Aug 30, 2016

Auto merge of #36145 - jonathandturner:rollup, r=jonathandturner
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

Auto merge of #36145 - jonathandturner:rollup, r=jonathandturner
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

Auto merge of #36145 - jonathandturner:rollup, r=jonathandturner
Rollup of 11 pull requests

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

This comment has been minimized.

Show comment
Hide comment
@jonathandturner

jonathandturner Aug 30, 2016

Contributor

@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.

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

This comment has been minimized.

Show comment
Hide comment
@frewsxcv

frewsxcv Aug 30, 2016

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
Member

alexcrichton commented Aug 31, 2016

@bors: r+

@bors

This comment has been minimized.

Show comment
Hide comment
@bors

bors Aug 31, 2016

Contributor

📌 Commit 268b3f5 has been approved by alexcrichton

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

Rollup merge of #36101 - frewsxcv:debug-path-components, r=alexcrichton
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

Rollup merge of #36101 - frewsxcv:debug-path-components, r=alexcrichton
Implement `Debug` for `std::path::{Components,Iter}`.

None

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

Rollup merge of #36101 - frewsxcv:debug-path-components, r=alexcrichton
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

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