pub struct ErrorOnExcess;
Expand description
Forbid all excesses, raise fmt::Error
once encounter one.
When value.width()
is not greater than total_width
,
add pads as usual:
use zero_copy_pads::{PaddedValue, AlignRight, ErrorOnExcess};
let padded_value = PaddedValue {
handle_excess: ErrorOnExcess,
value: "abcdef",
pad_block: '-',
total_width: 9,
pad: AlignRight,
};
assert_eq!(padded_value.to_string(), "---abcdef");
When value.width()
is greater than total_width
,
return an Err
of fmt::Error
:
use zero_copy_pads::{PaddedValue, AlignRight, ErrorOnExcess};
let padded_value = PaddedValue {
handle_excess: ErrorOnExcess,
value: "abcdefghijkl",
pad_block: '-',
total_width: 9,
pad: AlignRight,
};
let mut output = String::new();
std::fmt::write(
&mut output,
format_args!("{}", padded_value),
).unwrap_err();
Trait Implementations§
Source§impl Clone for ErrorOnExcess
impl Clone for ErrorOnExcess
Source§fn clone(&self) -> ErrorOnExcess
fn clone(&self) -> ErrorOnExcess
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 ErrorOnExcess
impl Debug for ErrorOnExcess
Source§impl Default for ErrorOnExcess
impl Default for ErrorOnExcess
Source§fn default() -> ErrorOnExcess
fn default() -> ErrorOnExcess
Returns the “default value” for a type. Read more
Source§impl<Value, PadBlock> ExcessHandler<Value, PadBlock> for ErrorOnExcess
impl<Value, PadBlock> ExcessHandler<Value, PadBlock> for ErrorOnExcess
Source§impl<Value, PadBlock> From<ErrorOnExcess> for ExcessHandlingFunction<Value, PadBlock>
impl<Value, PadBlock> From<ErrorOnExcess> for ExcessHandlingFunction<Value, PadBlock>
Source§fn from(_: ErrorOnExcess) -> Self
fn from(_: ErrorOnExcess) -> Self
Converts to this type from the input type.
Source§impl PartialEq for ErrorOnExcess
impl PartialEq for ErrorOnExcess
impl Copy for ErrorOnExcess
impl Eq for ErrorOnExcess
impl StructuralPartialEq for ErrorOnExcess
impl<Value: Width, PadBlock: Display> UnitExcessHandler<Value, PadBlock> for ErrorOnExcess
Auto Trait Implementations§
impl Freeze for ErrorOnExcess
impl RefUnwindSafe for ErrorOnExcess
impl Send for ErrorOnExcess
impl Sync for ErrorOnExcess
impl Unpin for ErrorOnExcess
impl UnwindSafe for ErrorOnExcess
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