#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

#568 in Debugging

Download history 4/week @ 2024-02-13 54/week @ 2024-02-20 3/week @ 2024-02-27 1/week @ 2024-03-05 24/week @ 2024-03-12 40/week @ 2024-03-19 6/week @ 2024-03-26 22/week @ 2024-04-02

93 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