#display #format #light-weight #string-formatting

no-std display_utils

Lightweight and no_std-compatible string formatting utilities

5 releases (3 breaking)

0.4.0 Mar 5, 2021
0.3.0 Jan 12, 2021
0.2.0 Jan 11, 2021
0.1.1 Jan 9, 2021
0.1.0 Jan 9, 2021

#694 in Debugging

Download history 417/week @ 2024-08-26 288/week @ 2024-09-02 201/week @ 2024-09-09 106/week @ 2024-09-16 258/week @ 2024-09-23 159/week @ 2024-09-30 169/week @ 2024-10-07 361/week @ 2024-10-14 157/week @ 2024-10-21 189/week @ 2024-10-28 288/week @ 2024-11-04 392/week @ 2024-11-11 186/week @ 2024-11-18 331/week @ 2024-11-25 131/week @ 2024-12-02 370/week @ 2024-12-09

1,018 downloads per month

MIT license

34KB
548 lines

This no_std compatible library provides several useful constructs to format data in a human-readable fashion with zero allocations.

Why hand-roll annoying and verbose formatting code everywhere...

for i, item in list.iter().enumerate() {
	if i == list.len() - 1 {
		println!("{}", item);
	} else {
		print!("{} - ", item);
	}
}

...when you could just use this?

println!("{}", display_utils::join(list, " - "));

This library makes ingenious use of Rust's formatting abstractions to provide super flexible and powerful formatting utilities, without any allocations.

For more information, please see the documentation: https://docs.rs/display_utils


lib.rs:

This library aims to provide useful constructs to vastly simplify data formatting tasks.

Being a no_std library, no allocations will be made, ever. Even with this restriction however, the provided functions are flexible and ergonomic.

This code snippet:

for (i, item) in list.iter().enumerate() {
    if i == list.len() - 1 {
        println!("{}", item);
    } else {
        print!("{} - ", item);
    }
}

...simplifies to:

println!("{}", display_utils::join(list, " - "));

Other functions work in a similar fashion. Browser through the crate functions for an overview of what you can do.

Extension traits (DisplayExt, IteratorExt) which may be used to make method chains more readable.

No runtime deps