Crate leftpad_rs

Source
Expand description

Leftpad implementation in Rust.

This is a Rust implementation of the famous Leftpad NPM package with pad() and pad_char(). Based on the Go implementation I wrote back in 2018.

Examples:

  use leftpad_rs::{pad,pad_char};

  let r = pad("foo", 5);  // -> "  foo"

  let s = pad_char("foo", 6, 'X');    // -> "XXXfoo"

Functionsยง

pad
This module implements pad and pad_char. Left-pads the string with spaces.
pad_char
Left-pads the string with the supplied character.
pad_with
Useful alias