Trait indent_write::indentable::Indentable[][src]

pub trait Indentable: Sized + Display {
    fn indented(self, indent: &str) -> Indented<'_, Self> { ... }
fn indented_skip_initial(self, indent: &str) -> IndentedSkipIntial<'_, Self> { ... } }
Expand description

Methods for adapting Display objects to indent themselves when printed.

Provided methods

Wrap this object so that its Display representation is indented with the given indent. Each non-empty line of the formatted output will be prefixed with the indent.

Example:
use indent_write::indentable::Indentable;

let content = "Line 1\nLine 2\n\nLine 3\n";
let indented = content.indented("    ");
let result = indented.to_string();

assert_eq!(result, "    Line 1\n    Line 2\n\n    Line 3\n");

Wrap this object so that its Display representation is indented with the given indent. Each non-empty line except for the first of the formatted output will be prefixed with the indent.

Example:
use indent_write::indentable::Indentable;

let content = "Line 1\nLine 2\n\nLine 3\n";
let indented = content.indented_skip_initial("    ");
let result = indented.to_string();

assert_eq!(result, "Line 1\n    Line 2\n\n    Line 3\n");

Implementors