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

no-std aformat

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

5 releases

new 0.1.4 Jul 15, 2024
0.1.3 Jun 15, 2024
0.1.2 Jun 15, 2024
0.1.1 Jun 5, 2024
0.1.0 Jun 3, 2024

#178 in Value formatting

Download history 322/week @ 2024-06-02 305/week @ 2024-06-09 227/week @ 2024-06-16 16/week @ 2024-06-23 22/week @ 2024-06-30 98/week @ 2024-07-07

658 downloads per month

MIT license

7KB
85 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

~3.5MB
~66K SLoC