Function fmty::join_map_once
source · pub fn join_map_once<I, S, R, F>(
iter: I,
sep: S,
f: F
) -> JoinMapOnce<I::IntoIter, S, F>where
I: IntoIterator,
F: Fn(I::Item) -> R,
Expand description
Concatenates mapped Iterator
results with a separator between each, at
most once.
This is a non-Clone
alternative to join_map()
. It uses interior
mutability to take ownership of the iterator in the first call to
Display::fmt()
. As a result, JoinMapOnce
does not implement
Sync
.
Examples
let value = fmty::join_map_once(["hola", "mundo"], " ", fmty::to_ascii_uppercase);
assert_eq!(value.to_string(), "HOLA MUNDO");
assert_eq!(value.to_string(), "");