Struct zero_copy_pads::PaddedValue[][src]

pub struct PaddedValue<Value, PadBlock = char, HandleExcess = ExcessHandlingFunction<Value, PadBlock>, Pad = Alignment> where
    Value: Width,
    PadBlock: Display,
    HandleExcess: ExcessHandler<Value, PadBlock>,
    Pad: Pad<Value, PadBlock>, 
{ pub value: Value, pub pad_block: PadBlock, pub total_width: usize, pub pad: Pad, pub handle_excess: HandleExcess, }

Pad a single value.

Key traits:

  • Display: Displays the padded version of the value.

Example: Pad dash characters to the left of a string

use zero_copy_pads::{PaddedValue, AlignRight, PanicOnExcess};
let padded_value = PaddedValue {
    value: "abcdef",
    pad_block: '-',
    total_width: 9,
    pad: AlignRight,
    handle_excess: PanicOnExcess,
};
assert_eq!(padded_value.to_string(), "---abcdef");

Example: Use a builder (requires std feature)

use zero_copy_pads::{PaddedValueBuilder, AlignRight, PanicOnExcess};
let padded_value = PaddedValueBuilder::default()
    .value("abcdef")
    .pad_block('-')
    .total_width(9)
    .pad(AlignRight)
    .handle_excess(PanicOnExcess)
    .build()
    .unwrap();
assert_eq!(padded_value.to_string(), "---abcdef");

Fields

value: Value

Value to be padded.

pad_block: PadBlock

Block of the pad (expected to have width of 1).

total_width: usize

Total width to fulfill.

pad: Pad

How to pad.

handle_excess: HandleExcess

How to write when the actual width of value exceeds total_width.

Trait Implementations

impl<Value: Clone, PadBlock: Clone, HandleExcess: Clone, Pad: Clone> Clone for PaddedValue<Value, PadBlock, HandleExcess, Pad> where
    Value: Width,
    PadBlock: Display,
    HandleExcess: ExcessHandler<Value, PadBlock>,
    Pad: Pad<Value, PadBlock>, 
[src]

impl<Value: Copy, PadBlock: Copy, HandleExcess: Copy, Pad: Copy> Copy for PaddedValue<Value, PadBlock, HandleExcess, Pad> where
    Value: Width,
    PadBlock: Display,
    HandleExcess: ExcessHandler<Value, PadBlock>,
    Pad: Pad<Value, PadBlock>, 
[src]

impl<Value: Debug, PadBlock: Debug, HandleExcess: Debug, Pad: Debug> Debug for PaddedValue<Value, PadBlock, HandleExcess, Pad> where
    Value: Width,
    PadBlock: Display,
    HandleExcess: ExcessHandler<Value, PadBlock>,
    Pad: Pad<Value, PadBlock>, 
[src]

impl<Value, PadBlock, HandleExcess, Pad> Display for PaddedValue<Value, PadBlock, HandleExcess, Pad> where
    Value: Width,
    PadBlock: Display,
    HandleExcess: ExcessHandler<Value, PadBlock>,
    Pad: Pad<Value, PadBlock>, 
[src]

Auto Trait Implementations

impl<Value, PadBlock, HandleExcess, Pad> RefUnwindSafe for PaddedValue<Value, PadBlock, HandleExcess, Pad> where
    HandleExcess: RefUnwindSafe,
    Pad: RefUnwindSafe,
    PadBlock: RefUnwindSafe,
    Value: RefUnwindSafe

impl<Value, PadBlock, HandleExcess, Pad> Send for PaddedValue<Value, PadBlock, HandleExcess, Pad> where
    HandleExcess: Send,
    Pad: Send,
    PadBlock: Send,
    Value: Send

impl<Value, PadBlock, HandleExcess, Pad> Sync for PaddedValue<Value, PadBlock, HandleExcess, Pad> where
    HandleExcess: Sync,
    Pad: Sync,
    PadBlock: Sync,
    Value: Sync

impl<Value, PadBlock, HandleExcess, Pad> Unpin for PaddedValue<Value, PadBlock, HandleExcess, Pad> where
    HandleExcess: Unpin,
    Pad: Unpin,
    PadBlock: Unpin,
    Value: Unpin

impl<Value, PadBlock, HandleExcess, Pad> UnwindSafe for PaddedValue<Value, PadBlock, HandleExcess, Pad> where
    HandleExcess: UnwindSafe,
    Pad: UnwindSafe,
    PadBlock: UnwindSafe,
    Value: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<X> Pipe for X

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.