[−][src]Function display_utils::join_format
pub fn join_format<I, C, J>(iterator: I, callback: C, joiner: J) -> impl Display where
I: IntoIterator,
I::IntoIter: Clone,
C: Fn(I::Item, &mut Formatter<'_>) -> Result,
J: Display,
Concatenate iterator elements, separating each element pair with a given joiner, where each iterator element can be formatted using a callback.
The callback must be Fn and the iterator must be cloneable, because Display objects may be printed multiple times.
let strings = &["hello", "wonderful", "world"]; let output = join_format( strings.iter().enumerate(), |(i, string), f| write!(f, "{}={}", i, string), ", ", ); assert_eq!(output.to_string(), "0=hello, 1=wonderful, 2=world");