rust-functions 0.2.1

A collection of Rust utility functions (starting with format_number).
Documentation
  • Coverage
  • 40%
    2 out of 5 items documented0 out of 3 items with examples
  • Size
  • Source code size: 9.39 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.14 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 15s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • PeterCullenBurbery/rust-functions
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • PeterCullenBurbery

rust-functions

A collection of small, reusable Rust utility functions.
The first release includes format_number, a helper for formatting numbers in a human-friendly way.

Installation

Add this to your Cargo.toml:

[dependencies]

rust-functions = "0.2.1"

Usage

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"
}

License

MIT