Struct LeftPadder

Source
pub struct LeftPadder<'a> { /* private fields */ }
Available on crate feature slices only.
Expand description

Add padding to a string in its Display impl.

§Example

use core_extensions::strings::LeftPadder;
 
assert_eq!(LeftPadder::new("foo\n bar", 0).to_string(), "foo\n bar");
assert_eq!(LeftPadder::new("foo\n bar", 1).to_string(), " foo\n  bar");
assert_eq!(LeftPadder::new("foo\n bar", 2).to_string(), "  foo\n   bar");
assert_eq!(LeftPadder::new("foo\n bar", 4).to_string(), "    foo\n     bar");
 
 

Implementations§

Source§

impl<'a> LeftPadder<'a>

Source

pub fn new(string: &'a str, padding: usize) -> Self

Constructs a LeftPadder

Trait Implementations§

Source§

impl<'a> Clone for LeftPadder<'a>

Source§

fn clone(&self) -> LeftPadder<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for LeftPadder<'a>

Source§

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

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

impl<'a> Display for LeftPadder<'a>

Source§

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

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

impl<'a> Copy for LeftPadder<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for LeftPadder<'a>

§

impl<'a> RefUnwindSafe for LeftPadder<'a>

§

impl<'a> Send for LeftPadder<'a>

§

impl<'a> Sync for LeftPadder<'a>

§

impl<'a> Unpin for LeftPadder<'a>

§

impl<'a> UnwindSafe for LeftPadder<'a>

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> AsPhantomData for T
where T: ?Sized,

Source§

fn as_phantom(&self) -> PhantomData<Self>

Available on crate feature phantom only.
Gets a PhantomData<Self>. Read more
Source§

fn as_phantom_covariant(&self) -> PhantomData<fn() -> Self>

Available on crate feature phantom only.
Gets a PhantomData<fn() -> Self>, a covariant PhantomData.
Source§

fn as_phantom_contra(&self) -> PhantomData<fn(Self)>

Available on crate feature phantom only.
Gets a PhantomData<fn(Self)>, a contravariant PhantomData.
Source§

fn as_phantom_invariant(&self) -> PhantomData<fn(Self) -> Self>

Available on crate feature phantom only.
Gets a PhantomData<fn(Self) -> Self>, an invariant PhantomData.
Source§

const PHANTOM: PhantomData<Self> = PhantomData

Available on crate feature phantom only.
Gets a PhantomData<Self>. Read more
Source§

const PHANTOM_COVARIANT: PhantomData<fn() -> Self> = PhantomData

Available on crate feature phantom only.
Constructs a PhantomData<fn() -> T>, a covariant PhantomData. Read more
Source§

const PHANTOM_CONTRA: PhantomData<fn(Self)> = PhantomData

Available on crate feature phantom only.
Gets a PhantomData<fn(Self)>, a contravariant PhantomData. Read more
Source§

const PHANTOM_INVARIANT: PhantomData<fn(Self) -> Self> = PhantomData

Available on crate feature phantom only.
Gets a PhantomData<fn(Self) -> Self>, an invariant PhantomData. 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> CallExt for T
where T: ?Sized,

Source§

fn ref_call<P>(&self, params: P) -> Self::Returns
where Self: CallRef<P>,

Available on crate feature callable only.
For calling CallRef::ref_call_, with the ability to specify the types of the arguments.. Read more
Source§

fn mut_call<P>(&mut self, params: P) -> Self::Returns
where Self: CallMut<P>,

Available on crate feature callable only.
For calling CallMut::mut_call_, with the ability to specify the types of the arguments.. Read more
Source§

fn into_call<P>(self, params: P) -> Self::Returns
where Self: Sized + CallInto<P>,

Available on crate feature callable only.
For calling CallInto::into_call_, with the ability to specify the types of the arguments.. 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> SelfOps for T
where T: ?Sized,

Source§

fn eq_id(&self, other: &Self) -> bool

Available on crate feature self_ops only.
Compares the address of self with the address of other. Read more
Source§

fn piped<F, U>(self, f: F) -> U
where F: FnOnce(Self) -> U, Self: Sized,

Available on crate feature self_ops only.
Emulates the pipeline operator, allowing method syntax in more places. Read more
Source§

fn piped_ref<'a, F, U>(&'a self, f: F) -> U
where F: FnOnce(&'a Self) -> U,

Available on crate feature self_ops only.
The same as piped except that the function takes &Self Useful for functions that take &Self instead of Self. Read more
Source§

fn piped_mut<'a, F, U>(&'a mut self, f: F) -> U
where F: FnOnce(&'a mut Self) -> U,

Available on crate feature self_ops only.
The same as piped, except that the function takes &mut Self. Useful for functions that take &mut Self instead of Self.
Source§

fn mutated<F>(self, f: F) -> Self
where F: FnOnce(&mut Self), Self: Sized,

Available on crate feature self_ops only.
Mutates self using a closure taking self by mutable reference, passing it along the method chain. Read more
Source§

fn observe<F>(self, f: F) -> Self
where F: FnOnce(&Self), Self: Sized,

Available on crate feature self_ops only.
Observes the value of self, passing it along unmodified. Useful in long method chains. Read more
Source§

fn into_<T>(self) -> T
where Self: Into<T>,

Available on crate feature self_ops only.
Performs a conversion with Into. using the turbofish .into_::<_>() syntax. Read more
Source§

fn as_ref_<T: ?Sized>(&self) -> &T
where Self: AsRef<T>,

Available on crate feature self_ops only.
Performs a reference to reference conversion with AsRef, using the turbofish .as_ref_::<_>() syntax. Read more
Source§

fn as_mut_<T: ?Sized>(&mut self) -> &mut T
where Self: AsMut<T>,

Available on crate feature self_ops only.
Performs a mutable reference to mutable reference conversion with AsMut, using the turbofish .as_mut_::<_>() syntax. Read more
Source§

fn drop_(self)
where Self: Sized,

Available on crate feature self_ops only.
Drops self using method notation. Alternative to std::mem::drop. Read more
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

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

Source§

type Type = T

Available on crate feature type_identity only.
This is always Self.
Source§

fn into_type(self) -> Self::Type
where Self: Sized, Self::Type: Sized,

Available on crate feature type_identity only.
Converts a value back to the original type.
Source§

fn as_type(&self) -> &Self::Type

Available on crate feature type_identity only.
Converts a reference back to the original type.
Source§

fn as_type_mut(&mut self) -> &mut Self::Type

Available on crate feature type_identity only.
Converts a mutable reference back to the original type.
Source§

fn into_type_box(self: Box<Self>) -> Box<Self::Type>

Available on crate features type_identity and alloc only.
Converts a box back to the original type.
Source§

fn into_type_arc(self: Arc<Self>) -> Arc<Self::Type>

Available on crate features type_identity and alloc only.
Converts an Arc back to the original type. Read more
Source§

fn into_type_rc(self: Rc<Self>) -> Rc<Self::Type>

Available on crate features type_identity and alloc only.
Converts an Rc back to the original type. Read more
Source§

fn from_type(this: Self::Type) -> Self
where Self: Sized, Self::Type: Sized,

Available on crate feature type_identity only.
Converts a value back to the original type.
Source§

fn from_type_ref(this: &Self::Type) -> &Self

Available on crate feature type_identity only.
Converts a reference back to the original type.
Source§

fn from_type_mut(this: &mut Self::Type) -> &mut Self

Available on crate feature type_identity only.
Converts a mutable reference back to the original type.
Source§

fn from_type_box(this: Box<Self::Type>) -> Box<Self>

Available on crate features type_identity and alloc only.
Converts a box back to the original type.
Source§

fn from_type_arc(this: Arc<Self::Type>) -> Arc<Self>

Available on crate features type_identity and alloc only.
Converts an Arc back to the original type.
Source§

fn from_type_rc(this: Rc<Self::Type>) -> Rc<Self>

Available on crate features type_identity and alloc only.
Converts an Rc back to the original type.
Source§

impl<T> CloneBound for T
where T: ToOwned + ?Sized,