MarginTrimmable

Trait MarginTrimmable 

Source
pub trait MarginTrimmable {
    // Required method
    fn trim_margin_with<M: AsRef<str>>(
        &self,
        margin_prefix: M,
    ) -> Option<String>;

    // Provided method
    fn trim_margin(&self) -> Option<String> { ... }
}
Expand description

An interface for removing the margin of multi-line string-like objects.

Required Methods§

Source

fn trim_margin_with<M: AsRef<str>>(&self, margin_prefix: M) -> Option<String>

Removes blanks and the margin_prefix from multiline strings.

If the first or last line is blank (contains only whitespace, tabs, etc.) they are removed. From each remaining line leading blank characters and the subsequent are removed

§Returns
  • The trimmed string or None if not every line starts with a margin_prefix.
  • Strings without line break unmodified

Provided Methods§

Source

fn trim_margin(&self) -> Option<String>

Short-hand for trin_margin_with("|").

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§