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

pub trait Indentable: Sized + Display {
    #[must_use = "Indentables do nothing unless used"]
    fn indented(self, indent: &str) -> Indented<'_, Self> { ... }
#[must_use = "Indentables do nothing unless used"] fn indented_skip_initial(self, indent: &str) -> IndentedSkipIntial<'_, Self> { ... } }

Methods for adapting Display objects to indent themselves when printed.

Provided methods

#[must_use = "Indentables do nothing unless used"]
fn indented(self, indent: &str) -> Indented<'_, Self>
[src]

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");

#[must_use = "Indentables do nothing unless used"]
fn indented_skip_initial(self, indent: &str) -> IndentedSkipIntial<'_, Self>
[src]

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");
Loading content...

Implementors

impl<T: Display> Indentable for T[src]

Loading content...