Crate display_utils[−][src]
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.
Macros
concat | Concatenate arbitrarily many instances of different types. |
Structs
Concat | See |
DisplaySlice | See |
Join | See |
JoinFormat | See |
Lowercase | See |
Ordinal | See |
Repeat | See |
Replace | See |
ReplaceN | See |
UnicodeBlockBar | See |
Uppercase | See |
VerticalUnicodeBlockBars |
Traits
DisplayExt | Extension trait providing convenient access to the base functions in the crate root. |
IteratorExt | Extension trait providing convenient access to the base functions in the crate root. |
Functions
cmp | Lexicographically compares a Display object against a string. |
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. |
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 Display object. |
ordinal | Create an ordinal from a number. |
repeat | Repeat an object a certain number of times. |
replace | Replace instances of the |
replace_n | Replace the first n instances of the |
slice | Extract a slice from the given Display object, similar to indexing a |
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. |