literator 0.3.0

Efficient conversion of iterators to human-readable strings
Documentation
//! Adapters for [`Literator`].

use crate::fmt::Empty;

/// Helper for [`Literator::prefix_each()`].
#[derive(Clone, Copy)]
pub struct Prefix<T, P> {
    /// Item implementing a formatting trait.
    pub item: T,
    /// Displayable prefix.
    pub prefix: P,
}

/// Helper for [`Literator::suffix_each()`].
#[derive(Clone, Copy)]
pub struct Suffix<T, S> {
    /// Item implementing a formatting trait.
    pub item: T,
    /// Displayable suffix.
    pub suffix: S,
}

/// Helper for [`Literator::surround_each()`].
pub struct Surround<T, Prefix = Empty, Suffix = Empty> {
    /// Item implementing a formatting trait.
    pub item: T,
    /// Displayable prefix.
    pub prefix: Prefix,
    /// Displayable suffix.
    pub suffix: Suffix,
}

/// Helper for [`Literator::prefix_each_with()`].
#[derive(Clone, Copy)]
pub struct PrefixWith<T, F> {
    /// Item implementing a formatting trait.
    pub item: T,
    /// Function to call to display the prefix.
    pub with: F,
}

/// Helper for [`Literator::suffix_each_with()`].
#[derive(Clone, Copy)]
pub struct SuffixWith<T, F> {
    /// Item implementing a formatting trait.
    pub item: T,
    /// Function to call to display the suffix.
    pub with: F,
}