#formatting #array #array-string #no-alloc #string-formatting #no-std

no-std aformat

A no-std and no-alloc version of format! using ToArrayString

9 releases

0.1.8 Oct 6, 2024
0.1.7 Sep 7, 2024
0.1.4 Jul 15, 2024
0.1.3 Jun 15, 2024

#104 in Value formatting

Download history 192/week @ 2024-07-30 244/week @ 2024-08-06 162/week @ 2024-08-13 165/week @ 2024-08-20 342/week @ 2024-08-27 425/week @ 2024-09-03 218/week @ 2024-09-10 140/week @ 2024-09-17 101/week @ 2024-09-24 360/week @ 2024-10-01 151/week @ 2024-10-08 229/week @ 2024-10-15 99/week @ 2024-10-22 118/week @ 2024-10-29 393/week @ 2024-11-05 487/week @ 2024-11-12

1,140 downloads per month

MIT license

8KB
92 lines

aformat

A no-std and no-alloc version of format! using ToArrayString.

Read the documentation via cargo doc --open --no-deps or on docs.rs.

Minimum Supported Rust Version

This is currently 1.79, and is considered a breaking change to increase.

Credits

  • @danielhenrymantilla, aka yandros, for providing much of the tricks needed to implement this on stable.
  • Everyone who has contributed to typenum, again for stable compatiblity.
  • The rustc developers, who unknowingly stablized enough features for this to work.

lib.rs:

A no-std and no-alloc version of format! using ToArrayString.

Example

use aformat::{astr, aformat, CapStr};

pub fn say_hello(name: &str, age: u8) {
    let name = CapStr::<256>(name);

    let formatted = aformat!("Hello {name}, you are {age} years old!");
    println!("{}", formatted.as_str());
}

say_hello("Walter White", 50);

Minimum Supported Rust Version

This is currently 1.79, and is considered a breaking change to increase.

Dependencies

~0.6–1.2MB
~26K SLoC