Alignment (Rust)
Tired of wasting your time trying to align your text to the center or left? I introduce to you: Alignment.
Alignment is a Rust library that lets you align your text to the center or left and optionally add padding on the "X" axis, always respecting the alignment (center or left).
Usage
Simple print ?
use align::{ print_center, print_right };
fn main() {
print_center(&["This", "text", "will be centered", "in the CLI"], None); print_center(&["This", "text", "will be centered", "in the CLI"], Some(20));
print_right(&["This", "text", "will be to", "the right", "in the CLI"], None); print_right(&["This", "text", "will be to", "the right", "in the CLI"], Some(20)); }
Stored in variable ?
use align::{ center, right };
fn main() {
let center_no_padding = center(&["This", "text", "will be centered", "in the CLI"], None); let center_with_padding = center(&["This", "text", "will be centered", "in the CLI"], Some(20));
let right_no_padding = right(&["This", "text", "will be to", "the right", "in the CLI"], None); let right_with_padding = right(&["This", "text", "will be to", "the right", "in the CLI"], Some(20)); }
Must know
I'm Zen-kun04, also known as Baguette. I started with Rust not long ago, so this is my first library (and Rust project).
I will, of course, maintain the library if I have some useful ideas and/or get suggestions from users.