Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/futile/leftpad-rs

Left-padding for strings in Rust.
https://github.com/futile/leftpad-rs

Last synced: 12 days ago
JSON representation

Left-padding for strings in Rust.

Awesome Lists containing this project

README

        

# leftpad-rs

##### Note: Rust's builtin `format!` can achieve the same functionality: https://doc.rust-lang.org/std/fmt/index.html#fillalignment

This crate provides generic left-padding functions for strings, including both `&str` and `String`.

Import with `extern crate left_pad;`.

## [Link to the documentation](https://futile.github.io/leftpad-rs/left_pad/index.html)

Usage example:

```rust
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");
```