9

Github tracking issue for `debug_non_exhaustive` feature · Issue #67364 · rust-l...

 3 years ago
source link: https://github.com/rust-lang/rust/issues/67364
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Copy link

Contributor

derekdreery commented on Dec 17, 2019

edited by m-ou-se

Feature gate: #![feature(debug_non_exhaustive)]

This is a tracking issue for adding the ability to add an ellipsis to the end of the Debug representation of a struct, to indicate that the struct has more fields, but that these fields are not displayable. This involves adding the finish_non_exhaustive method to DebugStruct, that produces output like

Name { field1: value1, .. }

where the .. indicate that there are more hidden fields.

Public API

// core::fmt

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

Steps / History

  • Implementation: #66716
  • Final commenting period (FCP): #67364 (comment)
  • Stabilization PR: #83041
  • Replace .finish() by .finish_non_exhaustive() within the standard library where it makes sense.

Unresolved Questions

  • Should this method be implemented for DebugTuple and DebugMap as well?
    • I would probably say "no" since I can't think of any use cases for them. They could always be added later.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK