Struct liquid_lib::stdlib::Truncate

source ·
pub struct Truncate;
Available on crate feature stdlib only.
Expand description

truncate shortens a string down to the number of characters passed as a parameter.

Note that this function operates on grapheme clusters (or user-perceived character), rather than Unicode code points. Each grapheme cluster may be composed of more than one Unicode code point, and does not necessarily correspond to rust’s conception of a character.

If the number of characters specified is less than the length of the string, an ellipsis (...) is appended to the string and is included in the character count.

Custom ellipsis

truncate takes an optional second parameter that specifies the sequence of characters to be appended to the truncated string. By default this is an ellipsis (...), but you can specify a different sequence.

The length of the second parameter counts against the number of characters specified by the first parameter. For example, if you want to truncate a string to exactly 10 characters, and use a 3-character ellipsis, use 13 for the first parameter of truncate, since the ellipsis counts as 3 characters.

No ellipsis

You can truncate to the exact number of characters specified by the first parameter and show no trailing characters by passing a blank string as the second parameter.

Trait Implementations§

source§

impl Clone for Truncate

source§

fn clone(&self) -> Truncate

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 FilterReflection for Truncate

source§

fn name(&self) -> &'static str

source§

fn description(&self) -> &'static str

source§

fn positional_parameters(&self) -> &'static [ParameterReflection]

source§

fn keyword_parameters(&self) -> &'static [ParameterReflection]

source§

impl ParseFilter for Truncate

source§

fn parse(&self, args: FilterArguments<'_>) -> Result<Box<dyn Filter>>

Filter input based on arguments.
source§

fn reflection(&self) -> &dyn FilterReflection

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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> ParseFilterClone for Twhere T: 'static + ParseFilter + Clone,

source§

fn clone_box(&self) -> Box<dyn ParseFilter + 'static, Global>

Cloning of dyn ParseFilter.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<T> Any for Twhere T: Any,

§

impl<T> CloneAny for Twhere T: Any + Clone,

§

impl<T> CloneAnySend for Twhere T: Any + Send + Clone,

§

impl<T> CloneAnySendSync for Twhere T: Any + Send + Sync + Clone,

§

impl<T> CloneAnySync for Twhere T: Any + Sync + Clone,