Skip to main content

StringExt

Trait StringExt 

Source
pub trait StringExt {
Show 20 methods // Required methods fn is_blank(&self) -> bool; fn truncate_with(&self, length: usize, omission: &str) -> String; fn truncate_words_with(&self, count: usize, omission: &str) -> String; fn squish(&self) -> String; fn remove(&self, pattern: &str) -> String; fn presence(&self) -> Option<&str>; fn camelize(&self) -> String; fn underscore(&self) -> String; fn dasherize(&self) -> String; fn titleize(&self) -> String; fn tableize(&self) -> String; fn classify(&self) -> String; fn pluralize(&self) -> String; fn singularize(&self) -> String; fn humanize(&self) -> String; fn foreign_key(&self) -> String; fn parameterize(&self) -> String; // Provided methods fn is_present(&self) -> bool { ... } fn truncate(&self, length: usize) -> String { ... } fn truncate_words(&self, count: usize) -> String { ... }
}
Expand description

Extension trait for string-like types.

Required Methods§

Source

fn is_blank(&self) -> bool

Returns true if the string is empty or contains only whitespace.

Source

fn truncate_with(&self, length: usize, omission: &str) -> String

Truncates to length characters, appending omission when needed.

Source

fn truncate_words_with(&self, count: usize, omission: &str) -> String

Truncates on word boundary, appending omission when needed.

Source

fn squish(&self) -> String

Strips leading/trailing whitespace and collapses internal whitespace to a single space.

Source

fn remove(&self, pattern: &str) -> String

Removes all occurrences of the pattern from the string.

Source

fn presence(&self) -> Option<&str>

Returns the string if present, otherwise None.

Source

fn camelize(&self) -> String

Converts to CamelCase.

Source

fn underscore(&self) -> String

Converts to snake_case.

Source

fn dasherize(&self) -> String

Converts to dash-case.

Source

fn titleize(&self) -> String

Converts to Title Case.

Source

fn tableize(&self) -> String

Converts to a table name.

Source

fn classify(&self) -> String

Converts to a class name.

Source

fn pluralize(&self) -> String

Converts to plural form.

Source

fn singularize(&self) -> String

Converts to singular form.

Source

fn humanize(&self) -> String

Converts to a humanized form.

Source

fn foreign_key(&self) -> String

Creates a foreign key name.

Source

fn parameterize(&self) -> String

Creates a URL-friendly slug.

Provided Methods§

Source

fn is_present(&self) -> bool

Returns true if the string is not blank.

Source

fn truncate(&self, length: usize) -> String

Truncates to length characters, appending ... when needed.

Source

fn truncate_words(&self, count: usize) -> String

Truncates on word boundary, appending ... when needed.

Implementations on Foreign Types§

Source§

impl StringExt for str

Source§

fn is_blank(&self) -> bool

Source§

fn truncate_with(&self, length: usize, omission: &str) -> String

Source§

fn truncate_words_with(&self, count: usize, omission: &str) -> String

Source§

fn squish(&self) -> String

Source§

fn remove(&self, pattern: &str) -> String

Source§

fn presence(&self) -> Option<&str>

Source§

fn camelize(&self) -> String

Source§

fn underscore(&self) -> String

Source§

fn dasherize(&self) -> String

Source§

fn titleize(&self) -> String

Source§

fn tableize(&self) -> String

Source§

fn classify(&self) -> String

Source§

fn pluralize(&self) -> String

Source§

fn singularize(&self) -> String

Source§

fn humanize(&self) -> String

Source§

fn foreign_key(&self) -> String

Source§

fn parameterize(&self) -> String

Source§

impl StringExt for String

Source§

fn is_blank(&self) -> bool

Source§

fn truncate_with(&self, length: usize, omission: &str) -> String

Source§

fn truncate_words_with(&self, count: usize, omission: &str) -> String

Source§

fn squish(&self) -> String

Source§

fn remove(&self, pattern: &str) -> String

Source§

fn presence(&self) -> Option<&str>

Source§

fn camelize(&self) -> String

Source§

fn underscore(&self) -> String

Source§

fn dasherize(&self) -> String

Source§

fn titleize(&self) -> String

Source§

fn tableize(&self) -> String

Source§

fn classify(&self) -> String

Source§

fn pluralize(&self) -> String

Source§

fn singularize(&self) -> String

Source§

fn humanize(&self) -> String

Source§

fn foreign_key(&self) -> String

Source§

fn parameterize(&self) -> String

Implementors§