pub trait Display {
// Required method
fn print_content(&self, out: &mut Output<'_>) -> Result;
// Provided methods
fn print(&self, out: &mut Output<'_>) -> Result { ... }
fn header_footer(&self) -> Option<(String, String)> { ... }
fn start_same_line(&self) -> bool { ... }
}Expand description
Display the value to the user.
This trait is kind of similar to std::fmt::Display, although far more simple.
This is a different trait than std::fmt::Display as graph exploring display may
be different than “classical” display.
Required Methods§
Sourcefn print_content(&self, out: &mut Output<'_>) -> Result
fn print_content(&self, out: &mut Output<'_>) -> Result
Print the content of the value.
If value is kind of a struct, header_footer should be implemented and
print_content should print only the fields of the value.
Else, print_content should simply print the value.
Provided Methods§
Sourcefn print(&self, out: &mut Output<'_>) -> Result
fn print(&self, out: &mut Output<'_>) -> Result
Print the value to out.
Default implementation reuse header_footer and print_content to display
the value, using a format like:
header
content
footeror simply (if not header/footer):
contentUser should probably not reimplement print.
Return the header and footer of the value.
Default implementation returns None.
One may want to implement it as:
Some((String::from("Foo:"), String::new()))Some((String::from("Foo("), String::from(")")))
Sourcefn start_same_line(&self) -> bool
fn start_same_line(&self) -> bool
Tell if value display can start on same line than prefix.
When the value render on several line and displayed as field value of parent structure,
if strat_same_line() is true,
the first line will be display on the same line of the field prefix:
foo: <first line>
<other lines>
...When start_same_line() is false:
foo:
<first line>
<other lines>
...Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".