Skip to main content

pad_left

Function pad_left 

Source
pub fn pad_left(s: &str, width: usize) -> String
Expand description

Pads a string on the left (right-aligns) to reach the target width.

ANSI escape codes are preserved and don’t count toward width calculations.

§Example

use standout::tabular::pad_left;

assert_eq!(pad_left("42", 5), "   42");
assert_eq!(pad_left("hello", 3), "hello");  // No truncation