pub struct PaddedColumn<ValueIter, PadBlock = char, Pad = Alignment>{
pub values: ValueIter,
pub pad_block: PadBlock,
pub pad: Pad,
}
Expand description
Pad all values in a collection to be of same (maximum) width.
Required features: std
Key traits:
IntoIterator
: Build an iterator of padded values.
Example:
use zero_copy_pads::{PaddedColumn, AlignRight};
let values = vec![
"Rust", "C", "C++", "C#", "JavaScript",
"TypeScript", "Java", "Kotlin", "Go",
];
let padded_column = PaddedColumn {
values: values.iter(),
pad_block: ' ',
pad: AlignRight,
};
let padded_values: Vec<_> = padded_column
.into_iter()
.map(|x| x.to_string())
.collect();
let expected = [
" Rust", " C", " C++",
" C#", "JavaScript", "TypeScript",
" Java", " Kotlin", " Go",
];
assert_eq!(padded_values, expected);
Fields§
§values: ValueIter
Values to be padded.
pad_block: PadBlock
Block of the pad (expected to have width of 1).
pad: Pad
Where to place the pad.
Trait Implementations§
Source§impl<ValueIter, PadBlock, Pad> Clone for PaddedColumn<ValueIter, PadBlock, Pad>
impl<ValueIter, PadBlock, Pad> Clone for PaddedColumn<ValueIter, PadBlock, Pad>
Source§fn clone(&self) -> PaddedColumn<ValueIter, PadBlock, Pad>
fn clone(&self) -> PaddedColumn<ValueIter, PadBlock, Pad>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<ValueIter, PadBlock, Pad> Debug for PaddedColumn<ValueIter, PadBlock, Pad>
impl<ValueIter, PadBlock, Pad> Debug for PaddedColumn<ValueIter, PadBlock, Pad>
Source§impl<ValueIter, PadBlock, Pad> IntoIterator for PaddedColumn<ValueIter, PadBlock, Pad>
impl<ValueIter, PadBlock, Pad> IntoIterator for PaddedColumn<ValueIter, PadBlock, Pad>
Source§type Item = PaddedValue<<ValueIter as Iterator>::Item, PadBlock, PanicOnExcess, Pad>
type Item = PaddedValue<<ValueIter as Iterator>::Item, PadBlock, PanicOnExcess, Pad>
The type of the elements being iterated over.
impl<ValueIter, PadBlock, Pad> Copy for PaddedColumn<ValueIter, PadBlock, Pad>
Auto Trait Implementations§
impl<ValueIter, PadBlock, Pad> Freeze for PaddedColumn<ValueIter, PadBlock, Pad>
impl<ValueIter, PadBlock, Pad> RefUnwindSafe for PaddedColumn<ValueIter, PadBlock, Pad>
impl<ValueIter, PadBlock, Pad> Send for PaddedColumn<ValueIter, PadBlock, Pad>
impl<ValueIter, PadBlock, Pad> Sync for PaddedColumn<ValueIter, PadBlock, Pad>
impl<ValueIter, PadBlock, Pad> Unpin for PaddedColumn<ValueIter, PadBlock, Pad>
impl<ValueIter, PadBlock, Pad> UnwindSafe for PaddedColumn<ValueIter, PadBlock, Pad>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more