Skip to main content

Literate

Struct Literate 

Source
pub struct Literate<I> { /* private fields */ }
Expand description

Adds Display/Debug formatting to any iterator whose items implement Display and/or Debug.

All formatting arguments are passed through to each item’s Display/Debug implementation.

Implementations§

Source§

impl<I: Sized> Literate<I>

Source

pub const fn new(iter: I) -> Self

Wrap an iterator in a Literate struct.

Source

pub const fn new_cell(iter: Option<I>) -> Self

Wrap an optional iterator in a Literate struct.

Source

pub fn into_inner(self) -> Option<I>

Consumes the Literate and returns the inner iterator. Returns None if the object has been formatted already.

Source

pub fn map_iterator<F, O>(self, f: F) -> Literate<O>
where F: FnOnce(I) -> O,

Convert the inner iterator to another inner iterator.

Trait Implementations§

Source§

impl<I: Clone> Clone for Literate<I>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<I> Debug for Literate<I>
where I: Iterator<Item: Debug>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I> Display for Literate<I>
where I: Iterator<Item: Display>,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<I> Literator for Literate<I>
where I: Iterator + Sized,

Source§

type Item = <I as Iterator>::Item

The item that this literator is displaying.
Source§

type Iter = I

The iterator type that this literator wraps.
Source§

fn into_option_iter(self) -> Option<Self::Iter>

Convert this literator into an Option of its iterator.
Source§

fn join<D>(self, delim: D) -> Join<Self::Iter, D>
where Self: Sized, D: Display,

Wrap the iterator in an object implementing Display/Debug that prints each item separated by a delimiter. Read more
Source§

fn concat(self) -> Literate<Self::Iter>
where Self: Sized,

Concatenate all items into a single string, using each item’s Display or Debug implementation. Read more
Source§

fn conjunctive_join_custom<Delim, LastDelim>( self, delim: Delim, last_delim: LastDelim, ) -> ConjunctiveJoin<Self::Iter, Delim, LastDelim>
where Self: Sized, Delim: Display, LastDelim: Display,

Join the items using delim between the first N-1 elements, and last_delim between the next-to-last and last items. Read more
Source§

fn join_and(self) -> ConjunctiveJoin<Self::Iter>
where Self: Sized,

Join the items separated by ", " between each item, except " and " (no comma) between the next-to-last and last items. Read more
Source§

fn join_or(self) -> ConjunctiveJoin<Self::Iter>
where Self: Sized,

Join the items separated by ", " between each item, except " or " (no comma) between the next-to-last and last items.
Source§

fn join_comma_and(self) -> ConjunctiveJoin<Self::Iter>
where Self: Sized,

Join the items separated by ", " between each item, except ", and " (with comma) between the next-to-last and last items. Read more
Source§

fn join_comma_or(self) -> ConjunctiveJoin<Self::Iter>
where Self: Sized,

Join the items separated by ", " between each item, except ", or " (with comma) between the next-to-last and last items.
Source§

fn oxford_join_custom<Delim, ExactlyTwo, Final>( self, first_n: Delim, exactly_two_conjunction: ExactlyTwo, final_delim_conjunction: Final, ) -> OxfordJoin<Self::Iter, Delim, ExactlyTwo, Final>
where Self: Sized, Delim: Display, ExactlyTwo: Display, Final: Display,

Join items using serial comma (“Oxford comma”, “Harvard comma”). Read more
Source§

fn oxford_join_and(self) -> OxfordJoin<Self::Iter>
where Self: Sized,

Oxford join with commas and English “and”. Read more
Source§

fn oxford_join_or(self) -> OxfordJoin<Self::Iter>
where Self: Sized,

Oxford join with commas and English “or”. Read more
Source§

fn oxford_join_semicolon_and(self) -> OxfordJoin<Self::Iter>
where Self: Sized,

Oxford join with semicolons and English “and”. Read more
Source§

fn oxford_join_semicolon_or(self) -> OxfordJoin<Self::Iter>
where Self: Sized,

Oxford join with semicolons and English “or”. Read more
Source§

fn format_each_with<F>( self, with: F, ) -> Literate<impl Iterator<Item = FormatWith<Self::Item, F>>>
where Self: Sized, F: Fn(&Self::Item, &mut Formatter<'_>) -> Result + Clone,

Produce an iterator where each item’s Display/Debug implementation is overridden by the function with. Read more
Source§

fn capitalize_first(self) -> Literate<impl Iterator<Item: Display>>
where Self: Sized, Self::Item: Display,

Capitalize the first item in the list. Read more
Source§

fn prefix_each_with<F>( self, with: F, ) -> Literate<impl Iterator<Item = PrefixWith<Self::Item, F>>>
where F: Fn(&Self::Item, &mut Formatter<'_>) -> Result + Clone, Self: Sized,

Produce an iterator where each item’s Display/Debug implementation writes a custom prefix before the item. Read more
Source§

fn suffix_each_with<F>( self, with: F, ) -> Literate<impl Iterator<Item = SuffixWith<Self::Item, F>>>
where F: Fn(&Self::Item, &mut Formatter<'_>) -> Result + Clone, Self: Sized,

Produce an iterator where each item’s Display/Debug implementation writes a custom suffix after the item. Read more
Source§

fn prefix_each<P>( self, prefix: P, ) -> Literate<impl Iterator<Item = Prefix<Self::Item, P>>>
where P: Display + Clone, Self: Sized,

Produce an iterator where each item’s Display/Debug implementation writes prefix before the item. Read more
Source§

fn suffix_each<S>( self, suffix: S, ) -> Literate<impl Iterator<Item = Suffix<Self::Item, S>>>
where S: Display + Clone, Self: Sized,

Produce an iterator where each item’s Display/Debug implementation writes suffix after the item. Read more
Source§

fn surround_each<P, S>( self, prefix: P, suffix: S, ) -> Literate<impl Iterator<Item = Surround<Self::Item, P, S>>>
where P: Display + Clone, S: Display + Clone, Self: Sized,

Produce an iterator where each item’s Display/Debug implementation writes prefix before and suffix after the item. Read more
Source§

fn indent_each( self, level: usize, ) -> Literate<impl Iterator<Item = Surround<Self::Item, Repeat<&'static str>, char>>>
where Self: Sized,

Print each item prefixed by indentation, where each level of indentation is 4 spaces, and suffix each item with a newline. Read more
Source§

fn indent_each_custom<P, S>( self, level: usize, indentation: P, newline: S, ) -> Literate<impl Iterator<Item = Surround<Self::Item, Repeat<P>, S>>>
where P: Display + Clone, S: Display + Clone, Self: Sized,

Print each item with custom indentation. The indentation string is repeated level times before each item, and newline is appended after each item.
Source§

fn indented_block<Open, Close>( self, open: Open, close: Close, inner_level: usize, ) -> IndentedBlock<Self::Iter, Open, Close, &'static str, char>
where Self: Sized, Open: Display, Close: Display,

Print items in a block surrounded by open and close, indented by inner_level. Read more
Source§

fn indented_block_custom<Open, Close, Indentation, Newline>( self, open: Open, close: Close, inner_level: usize, indentation: Indentation, newline: Newline, ) -> IndentedBlock<Self::Iter, Open, Close, Indentation, Newline>
where Self: Sized, Open: Display, Close: Display, Indentation: Display, Newline: Display,

Same as indented_block(), but with custom indentation and newline tokens. Read more
Source§

fn inline_block<P, D, S>( self, open: P, delim: D, close: S, ) -> InlineBlock<Self::Iter, P, D, S>
where Self: Sized, P: Display, D: Display, S: Display,

Print items in a block surrounded by open and close, where items are delimited by delim. Read more

Auto Trait Implementations§

§

impl<I> !Freeze for Literate<I>

§

impl<I> !RefUnwindSafe for Literate<I>

§

impl<I> !Sync for Literate<I>

§

impl<I> Send for Literate<I>
where I: Send,

§

impl<I> Unpin for Literate<I>
where I: Unpin,

§

impl<I> UnsafeUnpin for Literate<I>
where I: UnsafeUnpin,

§

impl<I> UnwindSafe for Literate<I>
where I: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.