text_align

Crates.iotext_align
lib.rstext_align
version0.3.1
sourcesrc
created_at2021-12-26 04:39:07.500183
updated_at2021-12-29 07:42:15.796353
descriptionA crate that provides a single trait for various alignments of text
homepage
repositoryhttps://github.com/JosephTLyons/text_align_rust
max_upload_size
id503196
size50,839
Joseph T. Lyons (JosephTLyons)

documentation

README

text_align

A Rust crate that provides a single trait for various alignments of text

use text_align::TextAlign;

fn main() {
    assert_eq!(
        "                          Hello my dearest friend!".left_align(50),
        "Hello my dearest friend!                          "
    );

    assert_eq!(
        "Hello my dearest friend!".right_align(50),
        "                          Hello my dearest friend!"
    );

    assert_eq!(
        "Hello my dearest friend!".center_align(50),
        "             Hello my dearest friend!             "
    );

    assert_eq!(
        "Hello my dearest friend!".justify(50),
        "Hello          my          dearest         friend!"
    );

    assert_eq!(
        "Hello          my          dearest         friend!".dejustify(2),
        "Hello my dearest friend!"
    );
}
Commit count: 67

cargo fmt