pub trait DisplayIterator: Iterator + Clone{
// Provided methods
fn display_concat(self) -> Concat<Self>
where Self: Sized { ... }
fn display_join<S>(self, sep: S) -> Join<Self, S>
where Self: Sized,
S: Display { ... }
}Expand description
Extension trait for iterators of Display items.
Adds display_concat() and display_join() to any iterator whose items implement
Display. Both methods return lazy wrappers that themselves implement Display,
so no allocation happens until someone writes the result to a formatter or calls
.to_string().
§Design note
The trait requires Iterator + Clone (not IntoIterator) because Display::fmt
takes &self — it cannot consume the iterator. The wrapper clones the iterator on
each fmt call. For typical iterators (slice iterators, std::iter::Copied, etc.)
this clone is two pointer copies — effectively free.
Provided Methods§
fn display_concat(self) -> Concat<Self>where
Self: Sized,
fn display_join<S>(self, sep: S) -> Join<Self, S>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.