Function local_strtools::pad
source · pub fn pad(str: String, l: usize) -> StringExpand description
Pads a string with zeros, resulted string would be in length given in second argument
§Examples
let str = String::from("9");
let padded_string = strtools::pad(str, 3);
assert_eq!(padded_string, "009");§Panics
When length of given string is bigger than the wanted to be length, program panics:
#[should_panic]
fn can_panic() {
let str = String::from("98798");
strtools::pad(str, 3);
}