Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/futile/leftpad-rs
- Owner: futile
- License: mit
- Created: 2016-03-24T08:25:00.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-04-07T08:06:42.000Z (over 8 years ago)
- Last Synced: 2024-10-12T19:54:29.009Z (27 days ago)
- Language: Rust
- Homepage: https://futile.github.io/leftpad-rs
- Size: 521 KB
- Stars: 19
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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");
```