[−][src]Crate display_utils
This library provides several useful constructs to format data in a human-readable fashion with zero allocations
Some of these functions may seem to partly reinvent existing std functionality, for example
join
:
println!("{}", display_utils::join(&[1, 2, 3], " + ")); println!("{}", ["1", "2", "3"].join(" + ")); println!("{}", display_utils::repeat("abc", 4)); println!("{}", "abc".repeat(4));
The important difference is that the std approach involves 4 allocations, whereas the display_utils approach operates 100% on stack and is therefore no_std compatible and likely faster.
Functions
collect_str | Write a Display object into a fixed-size buffer and returns the resulting &str. |
collect_str_mut | Write a Display object into a fixed-size buffer and returns the resulting &mut str. |
concat | Concatenate the contents of an iterator. |
indent_4 | Indent to a given depth using 4 spaces. |
indent_tab | Indent to a given depth using the tab character. |
join | Concatenate iterator elements, separating each element pair with a given joiner. |
join_format | Concatenate iterator elements, separating each element pair with a given joiner, where each iterator element can be formatted using a callback. |
lowercase | Print a Unicode-compliant lowercase version of the string. |
repeat | Repeat an object a certain number of times. |
replace | Replace instances of the |
replace_n | Replace the first n instances of the |
unicode_block_bar | Print a loading-style bar using Unicode block characters. |
uppercase | Print a Unicode-compliant uppercase version of the string. |
vertical_unicode_block_bars | Print a sequence of equalizer-style vertical bars using Unicode block characters. |