[][src]Trait stripmargin::StripMargin

pub trait StripMargin {
    pub fn strip_margin_with(&self, margin_char: char) -> String;

    pub fn strip_margin(&self) -> String { ... }
}

Required methods

pub fn strip_margin_with(&self, margin_char: char) -> String[src]

For every line in this string, strip a leading prefix consisting of blanks or control characters, followed by margin_char from the line.

Examples

use stripmargin::StripMargin;
assert_eq!(
    r#"Hello,
      @  world!
      @"#
    .strip_margin_with('@'),
    "Hello,\n  world!\n",
);

Please note that a non-whitespace margin won't get stripped:

use stripmargin::StripMargin;
assert_eq!(
    "Hello * world!".strip_margin_with('*'),
    "Hello * world!",
);
Loading content...

Provided methods

pub fn strip_margin(&self) -> String[src]

Shorthand for strip_margin_with('|').

For every line in this string, strip a leading prefix consisting of blanks or control characters, followed by '|' from the line.

Examples

use stripmargin::StripMargin;
assert_eq!(
    r#"Hello,
      |  world!
      |"#
    .strip_margin(),
    "Hello,\n  world!\n",
);

Please note that a non-whitespace margin won't get stripped:

use stripmargin::StripMargin;
assert_eq!(
    "Hello | world!".strip_margin(),
    "Hello | world!",
);
Loading content...

Implementors

impl<S: AsRef<str>> StripMargin for S[src]

Loading content...