pub struct AlignCenterLeft;
Expand description
Pad to both sides, place content in the middle, but shift to the left one block if it can’t be exactly central.
Example:
use zero_copy_pads::{AlignCenterLeft, PaddedColumn, PanicOnExcess};
let values = [
"Rust", "C", "C++", "C#", "JavaScript",
"TypeScript", "Java", "Kotlin", "Go",
];
let padded_column = PaddedColumn {
pad: AlignCenterLeft,
values: values.iter(),
pad_block: '-',
};
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);
Trait Implementations§
Source§impl Clone for AlignCenterLeft
impl Clone for AlignCenterLeft
Source§fn clone(&self) -> AlignCenterLeft
fn clone(&self) -> AlignCenterLeft
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 Debug for AlignCenterLeft
impl Debug for AlignCenterLeft
Source§impl Default for AlignCenterLeft
impl Default for AlignCenterLeft
Source§fn default() -> AlignCenterLeft
fn default() -> AlignCenterLeft
Returns the “default value” for a type. Read more
Source§impl PartialEq for AlignCenterLeft
impl PartialEq for AlignCenterLeft
Source§impl Unit for AlignCenterLeft
impl Unit for AlignCenterLeft
impl Copy for AlignCenterLeft
impl Eq for AlignCenterLeft
impl StructuralPartialEq for AlignCenterLeft
impl<Value: Width, PadBlock: Display> UnitPad<Value, PadBlock> for AlignCenterLeft
Auto Trait Implementations§
impl Freeze for AlignCenterLeft
impl RefUnwindSafe for AlignCenterLeft
impl Send for AlignCenterLeft
impl Sync for AlignCenterLeft
impl Unpin for AlignCenterLeft
impl UnwindSafe for AlignCenterLeft
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