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§
Sourcefn truncate_with(&self, length: usize, omission: &str) -> String
fn truncate_with(&self, length: usize, omission: &str) -> String
Truncates to length characters, appending omission when needed.
Sourcefn truncate_words_with(&self, count: usize, omission: &str) -> String
fn truncate_words_with(&self, count: usize, omission: &str) -> String
Truncates on word boundary, appending omission when needed.
Sourcefn squish(&self) -> String
fn squish(&self) -> String
Strips leading/trailing whitespace and collapses internal whitespace to a single space.
Sourcefn remove(&self, pattern: &str) -> String
fn remove(&self, pattern: &str) -> String
Removes all occurrences of the pattern from the string.
Sourcefn underscore(&self) -> String
fn underscore(&self) -> String
Converts to snake_case.
Sourcefn singularize(&self) -> String
fn singularize(&self) -> String
Converts to singular form.
Sourcefn foreign_key(&self) -> String
fn foreign_key(&self) -> String
Creates a foreign key name.
Sourcefn parameterize(&self) -> String
fn parameterize(&self) -> String
Creates a URL-friendly slug.
Provided Methods§
Sourcefn is_present(&self) -> bool
fn is_present(&self) -> bool
Returns true if the string is not blank.
Sourcefn truncate(&self, length: usize) -> String
fn truncate(&self, length: usize) -> String
Truncates to length characters, appending ... when needed.
Sourcefn truncate_words(&self, count: usize) -> String
fn truncate_words(&self, count: usize) -> String
Truncates on word boundary, appending ... when needed.