4 stable releases

1.1.0 Apr 11, 2024
1.0.2 Dec 1, 2023
1.0.0 Jul 18, 2022

#227 in Embedded development

Download history 40/week @ 2024-01-06 3/week @ 2024-01-13 7/week @ 2024-01-20 20/week @ 2024-02-17 66/week @ 2024-02-24 16/week @ 2024-03-02 22/week @ 2024-03-09 17/week @ 2024-03-16 6/week @ 2024-03-23 83/week @ 2024-03-30 141/week @ 2024-04-06 57/week @ 2024-04-13 24/week @ 2024-04-20

305 downloads per month

MIT/Apache

7KB
54 lines

format_no_std

Implements write_str to get write_fmt, which is used in the format!() and format_args!() macros. For no_std formatting in a bare metal environment.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Usage

Library usage example

let mut buf = [0u8; 64];
let s = format_no_std::show(
    &mut buf,
    format_args!("Test String {}: {}", "foo", 42),
).unwrap();

assert_eq!("Test String foo: 42", s);

lib.rs:

Implements write_str to get write_fmt, which is used in the format!() and format_args!() macros. For no_std formatting in a bare metal environment.

This code is based on https://stackoverflow.com/questions/50200268/how-can-i-use-the-format-macro-in-a-no-std-environment

let mut buf = [0u8; 64];
let s = format_no_std::show(
    &mut buf,
    format_args!("Test String {}: {}", "foo", 42),
).unwrap();

assert_eq!("Test String foo: 42", s);

No runtime deps