Struct core::fmt::DebugStruct1.2.0 [] [src]

pub struct DebugStruct<'a, 'b: 'a> { /* fields omitted */ }

A struct to help with fmt::Debug implementations.

This is useful when you wish to output a formatted struct as a part of your Debug::fmt implementation.

This can be constructed by the Formatter::debug_struct method.


use std::fmt;

struct Foo {
    bar: i32,
    baz: String,

impl fmt::Debug for Foo {
    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
           .field("bar", &
           .field("baz", &self.baz)

// prints "Foo { bar: 10, baz: "Hello World" }"
println!("{:?}", Foo { bar: 10, baz: "Hello World".to_string() });Run


impl<'a, 'b: 'a> DebugStruct<'a, 'b>


Adds a new field to the generated struct output.


Finishes output and returns any error encountered.