#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

#660 in Debugging

Download history 1/week @ 2024-03-23 21/week @ 2024-03-30 7/week @ 2024-04-06 2/week @ 2024-04-20 4/week @ 2024-04-27 1/week @ 2024-06-08 1/week @ 2024-06-15 265/week @ 2024-06-29 545/week @ 2024-07-06

811 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