about summary refs log tree commit diff
path: root/src/libstd/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-01-17 00:20:48 +0000
committerbors <bors@rust-lang.org>2020-01-17 00:20:48 +0000
commit8cacf50563ba0f60855d3465f019290d29495ec1 (patch)
tree9efd2b59f04a6da177d33545676bd1d346a5e83b /src/libstd/sys/unix/stack_overflow.rs
parentecbc222855c890c3aabe4848e8d8b312debcf0ff (diff)
parent73124df6eba9d81affb3ef597fdaeb4fce82f7af (diff)
downloadrust-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/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions