| Crates.io | rust-functions |
| lib.rs | rust-functions |
| version | 0.2.1 |
| created_at | 2025-10-01 21:07:07.315624+00 |
| updated_at | 2025-10-01 22:10:27.712948+00 |
| description | A collection of Rust utility functions (starting with format_number). |
| homepage | https://github.com/PeterCullenBurbery/rust-functions |
| repository | https://github.com/PeterCullenBurbery/rust-functions |
| max_upload_size | |
| id | 1863486 |
| size | 9,891 |
A collection of small, reusable Rust utility functions.
The first release includes format_number, a helper for formatting numbers in a human-friendly way.
Add this to your Cargo.toml:
[dependencies]
rust-functions = "0.2.1"
The format_number function supports both &str and usize as the group size argument.
use rust_functions::number_formatting::format_number;
fn main() {
// Default group size (3) when passing ""
println!("{}", format_number("1234567", ""));
// → "001_234_567"
// Explicit group size as string
println!("{}", format_number("1234567", "4"));
// → "0123_4567"
// Explicit group size as usize
println!("{}", format_number("1234567", 4));
// → "0123_4567"
// Handles decimals
println!("{}", format_number("1234.5678", 3));
// → "001_234_decimal_point_567_800"
// Handles negatives
println!("{}", format_number("-1234", ""));
// → "negative_001_234"
}
MIT