Crate left_pad [] [src]

This crate provides left-padding for strings (including both &str and String).

Import with extern crate left_pad;.

Usage example:

use left_pad::{leftpad, leftpad_with};

assert_eq!(leftpad("blubb", 7), "  blubb");
assert_eq!(leftpad_with("blubb", 7, '.'), "..blubb");

let s: String = "blubb".to_owned();
assert_eq!(leftpad(s, 7), "  blubb");

Functions

leftpad

Pads a string to the given length len by inserting whitespaces from the left.

leftpad_with

Pads a string to the given length len by inserting the character pad_char from the left.