| Crates.io | leftpad-rs |
| lib.rs | leftpad-rs |
| version | 1.2.0 |
| created_at | 2021-10-08 21:19:28.914232+00 |
| updated_at | 2021-11-04 14:16:52.50326+00 |
| description | Rust implementation of the Go Leftpad package. |
| homepage | |
| repository | https://github.com/keltia/leftpad-rs |
| max_upload_size | |
| id | 462499 |
| size | 7,919 |
Rust package to left pad a string with a character.
Inspired by the "left-pad" NPM package (and the fiasco that happened after its removal).
Supported Platforms
use leftpad_rs::{pad,pad_char,pad_with};
fn main() {
let s = "foo";
println!("{}", pad(s, 5));
let s1 = match pad_char(s, 6, ' ')) {
Ok(s) => s,
Err(e) => Err("Error: {}", e)
};
println!("{:?}", s1);
// You can use pad_with() too now.
You can use this package in your project by adding the following
to your Cargo.toml:
[dependencies]
leftpad-rs = "1.1.0"
then you can use it in your own crates.