Trait workflow_terminal::terminal::PadStr

source ·
pub trait PadStr {
    // Required method
    fn pad(
        &self,
        width: usize,
        pad_char: char,
        alignment: Alignment,
        truncate: bool,
    ) -> String;

    // Provided methods
    fn pad_to_width(&self, width: usize) -> String { ... }
    fn pad_to_width_with_char(&self, width: usize, pad_char: char) -> String { ... }
    fn pad_to_width_with_alignment(
        &self,
        width: usize,
        alignment: Alignment,
    ) -> String { ... }
    fn with_exact_width(&self, width: usize) -> String { ... }
}
Expand description

Functions to do with string padding.

Required Methods§

source

fn pad( &self, width: usize, pad_char: char, alignment: Alignment, truncate: bool, ) -> String

Pad a string to the given width somehow.

Provided Methods§

source

fn pad_to_width(&self, width: usize) -> String

Pad a string to be at least the given width by adding spaces on the right.

source

fn pad_to_width_with_char(&self, width: usize, pad_char: char) -> String

Pad a string to be at least the given width by adding the given character on the right.

source

fn pad_to_width_with_alignment( &self, width: usize, alignment: Alignment, ) -> String

Pad a string to be at least the given with by adding spaces around it.

source

fn with_exact_width(&self, width: usize) -> String

Pad a string to be exactly the given width by either adding spaces on the right, or by truncating it to that width.

Implementations on Foreign Types§

source§

impl PadStr for str

source§

fn pad( &self, width: usize, pad_char: char, alignment: Alignment, truncate: bool, ) -> String

Implementors§