Expand description
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
concat()
. - Display
Slice - See
slice()
; - Join
- See
join()
. - Join
Format - See
join_format()
. - Lowercase
- See
lowercase()
. - Ordinal
- See
ordinal()
. - Repeat
- See
repeat()
. - Replace
- See
replace()
. - ReplaceN
- See
replace_n()
. - Unicode
Block Bar - See
unicode_block_bar()
. - Uppercase
- See
uppercase()
. - Vertical
Unicode Block Bars - See
vertical_unicode_block_bars()
.
Traits§
- Display
Ext - Extension trait providing convenient access to the base functions in the crate root.
- Iterator
Ext - 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
from
string with theto
Display object. - replace_
n - Replace the first n instances of the
from
string with theto
string. - slice
- Extract a slice from the given Display object, similar to indexing a
&str
. - 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.