Struct liquid_lib::stdlib::Truncate
source · [−]pub struct Truncate;
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
sourceimpl FilterReflection for Truncate
impl FilterReflection for Truncate
fn name(&self) -> &'static str
fn description(&self) -> &'static str
fn positional_parameters(&self) -> &'static [ParameterReflection]
fn keyword_parameters(&self) -> &'static [ParameterReflection]
sourceimpl ParseFilter for Truncate
impl ParseFilter for Truncate
sourcefn parse(&self, args: FilterArguments<'_>) -> Result<Box<dyn Filter>>
fn parse(&self, args: FilterArguments<'_>) -> Result<Box<dyn Filter>>
Filter input
based on arguments
.
fn reflection(&self) -> &dyn FilterReflection
Auto Trait Implementations
impl RefUnwindSafe for Truncate
impl Send for Truncate
impl Sync for Truncate
impl Unpin for Truncate
impl UnwindSafe for Truncate
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ParseFilterClone for T where
T: 'static + ParseFilter + Clone,
impl<T> ParseFilterClone for T where
T: 'static + ParseFilter + Clone,
sourcefn clone_box(&self) -> Box<dyn ParseFilter + 'static, Global>
fn clone_box(&self) -> Box<dyn ParseFilter + 'static, Global>
Cloning of dyn ParseFilter
.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more