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

Tracking Issue for debug_more_non_exhaustive #127942

Open
1 of 4 tasks
tgross35 opened this issue Jul 18, 2024 · 3 comments
Open
1 of 4 tasks

Tracking Issue for debug_more_non_exhaustive #127942

tgross35 opened this issue Jul 18, 2024 · 3 comments
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@tgross35
Copy link
Contributor

tgross35 commented Jul 18, 2024

Feature gate: #![feature(debug_more_non_exhaustive)]

This is a tracking issue for the non_exhaustive() function on fmt::Debug{List, Map, Set, Tuple}, which provides an easy way to omit fields with ...

Public API

// core::fmt

impl<'a, 'b: 'a> DebugList<'a, 'b> {
    pub fn finish_non_exhaustive(&mut self) -> Result<(), Error>;
}

impl<'a, 'b: 'a> DebugMap<'a, 'b> {
    pub fn finish_non_exhaustive(&mut self) -> Result<(), Error>;
}

impl<'a, 'b: 'a> DebugSet<'a, 'b> {
    pub fn finish_non_exhaustive(&mut self) -> Result<(), Error>;
}

impl<'a, 'b: 'a> DebugTuple<'a, 'b> {
    pub fn finish_non_exhaustive(&mut self) -> Result<(), Error>;
}

Steps / History

Unresolved Questions

  • None yet.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

@tgross35 tgross35 added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. labels Jul 18, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 21, 2024
…, r=Noratrieb

Implement `debug_more_non_exhaustive`

This implements the ACP at rust-lang/libs-team#248, adding `.finish_non_exhaustive()` for `DebugTuple`, `DebugSet`, `DebugList`, and `DebugMap`.

Also used this as an opportunity to make some documentation and tests more readable by using raw strings instead of escaped quotes.

Tracking issue: rust-lang#127942
jieyouxu added a commit to jieyouxu/rust that referenced this issue Aug 22, 2024
…, r=Noratrieb

Implement `debug_more_non_exhaustive`

This implements the ACP at rust-lang/libs-team#248, adding `.finish_non_exhaustive()` for `DebugTuple`, `DebugSet`, `DebugList`, and `DebugMap`.

Also used this as an opportunity to make some documentation and tests more readable by using raw strings instead of escaped quotes.

Tracking issue: rust-lang#127942
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 22, 2024
Rollup merge of rust-lang#127945 - tgross35:debug-more-non-exhaustive, r=Noratrieb

Implement `debug_more_non_exhaustive`

This implements the ACP at rust-lang/libs-team#248, adding `.finish_non_exhaustive()` for `DebugTuple`, `DebugSet`, `DebugList`, and `DebugMap`.

Also used this as an opportunity to make some documentation and tests more readable by using raw strings instead of escaped quotes.

Tracking issue: rust-lang#127942
@clarfonthey
Copy link
Contributor

Small bit of feedback as I'm looking through this, but it feels like it might be useful to actually have the non_exhaustive marker anywhere inside these, rather than just at the end.

Example where it'd be useful: I'm working on a tool to help more easily verify that double-ended iterators are working, and they accumulate their data into a VecDeque that gets rotated back to the correct position once everything has been accumulated. Therefore, when displaying this data in a Debug impl, it would make more sense to indicate the "non-exhaustive" marker in the middle of the list, rather than at the end, since the missing elements will end up between the ones that have already been added to the beginning and end.

While structs have no order to their fields (and thus, adding to the end is appropriate every time), lists do have relevant order here, and it feels reasonable to put the marker in the middle.

For now, I'll just add a RangeFull entry anyway since that covers it, but it feels like it would be reasonable to do it as a field rather than just a finish_non_exhaustive like structs do it.

@tgross35
Copy link
Contributor Author

That is an interesting idea. Are you imagining that this would be something like .field_elided().finish() rather than .finish_non_exhaustive()?

@clarfonthey
Copy link
Contributor

That's pretty much what I was thinking. I hadn't thought of a good name for it, but, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants