diff options
| author | bors <bors@rust-lang.org> | 2020-01-17 00:20:48 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-01-17 00:20:48 +0000 |
| commit | 8cacf50563ba0f60855d3465f019290d29495ec1 (patch) | |
| tree | 9efd2b59f04a6da177d33545676bd1d346a5e83b /src/test/codegen/src-hash-algorithm | |
| parent | ecbc222855c890c3aabe4848e8d8b312debcf0ff (diff) | |
| parent | 73124df6eba9d81affb3ef597fdaeb4fce82f7af (diff) | |
| download | rust-8cacf50563ba0f60855d3465f019290d29495ec1.tar.gz rust-8cacf50563ba0f60855d3465f019290d29495ec1.zip | |
Auto merge of #66716 - derekdreery:debug_non_exhaustive, r=dtolnay
Implement `DebugStruct::non_exhaustive`.
This patch adds a function (finish_non_exhaustive) to add ellipsis before the closing brace when formatting using `DebugStruct`.
## Example
```rust
#![feature(debug_non_exhaustive)]
use std::fmt;
struct Bar {
bar: i32,
hidden: f32,
}
impl fmt::Debug for Bar {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Bar")
.field("bar", &self.bar)
.non_exhaustive(true) // Show that some other field(s) exist.
.finish()
}
}
assert_eq!(
format!("{:?}", Bar { bar: 10, hidden: 1.0 }),
"Bar { bar: 10, .. }",
);
```
Diffstat (limited to 'src/test/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions
