Skip to main content

TruncateWith

Struct TruncateWith 

Source
pub struct TruncateWith<T> { /* private fields */ }
Expand description

Truncates with a tail indicator (e.g., “…”).

max_chars is the total output budget including the tail. If the inner content fits within the budget, it passes through unchanged (no tail shown). If it exceeds the budget, inner content is truncated at max_chars - tail_chars and the tail is appended. Total output is always <= max_chars.

Trait Implementations§

Source§

impl<T: Display> Display for TruncateWith<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for TruncateWith<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TruncateWith<T>
where T: RefUnwindSafe,

§

impl<T> Send for TruncateWith<T>
where T: Send,

§

impl<T> Sync for TruncateWith<T>
where T: Sync,

§

impl<T> Unpin for TruncateWith<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TruncateWith<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for TruncateWith<T>
where T: UnwindSafe,

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> 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> DisplayExt for T
where T: Display + ?Sized,

Source§

fn is_empty(&self) -> bool

Source§

fn write_to_fmt<W>(&self, writer: W) -> Result<(), Error>
where W: Write,

Source§

fn write_to_bytes<W>(&self, writer: W) -> Result<(), Error>
where W: Write,

Source§

fn format_with<F>(&self, cb: F) -> Result<(), Error>
where F: FnMut(Option<&str>) -> Result<(), Error>,

Source§

fn try_to_fmt<T>(&self) -> Result<T, T>
where T: Write + Default,

Source§

fn try_to_bytes<T>(&self) -> Result<T, T>
where T: Write + Default,

Source§

fn to_fmt<T>(&self) -> T
where T: Write + Default,

Source§

fn to_bytes<T>(&self) -> T
where T: Write + Default,

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> SmartFormat for T
where T: Display,

Source§

fn display_wrap<P: Display, S: Display>( self, prefix: P, suffix: S, ) -> Wrap<Self, P, S>

Wrap with a prefix and suffix: prefix + self + suffix.
Source§

fn display_prefix<P: Display>(self, prefix: P) -> Prefix<Self, P>

Prepend a prefix: prefix + self.
Source§

fn display_suffix<S: Display>(self, suffix: S) -> Suffix<Self, S>

Append a suffix: self + suffix.
Source§

fn display_if(self, condition: bool) -> If<Self>

Conditionally display: if condition is true, display self; otherwise write nothing.
Source§

fn display_or_if<U: Display>( self, use_fallback: bool, fallback: U, ) -> Or<Self, U>

Conditionally choose: if use_fallback is false, display self; otherwise display fallback. Read more
Source§

fn display_truncate(self, max_chars: usize) -> Truncate<Self>

Truncate to at most max_chars Unicode scalar values. Read more
Source§

fn display_truncate_with( self, max_chars: usize, tail: &'static str, ) -> TruncateWith<Self>

Truncate with a tail indicator (e.g., “…”). Read more
Source§

fn display_pad_right(self, width: usize, fill: char) -> PadRight<Self>

Right-pad to width characters using fill. Read more
Source§

fn display_pad_left(self, width: usize, fill: char) -> PadLeft<Self>

Left-pad to width characters using fill. Read more
Source§

impl<T> SmartFormatCase for T
where T: Display,

Source§

fn capitalize(self) -> Capitalize<T>
where T: Display,

Source§

fn lowercase(self) -> Lowercase<T>
where T: Display,

Source§

fn uppercase(self) -> Uppercase<T>
where T: Display,

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.