Trait collections::str::StrAllocatingExperimental
[-]
[+]
[src]
pub trait StrAllocating: Str {
fn into_string(self) -> String;
fn escape_default(&self) -> String { ... }
fn escape_unicode(&self) -> String { ... }
fn replace(&self, from: &str, to: &str) -> String { ... }
fn repeat(&self, nn: uint) -> String { ... }
fn lev_distance(&self, t: &str) -> uint { ... }
fn nfd_chars<'a>(&'a self) -> Decompositions<'a> { ... }
fn nfkd_chars<'a>(&'a self) -> Decompositions<'a> { ... }
fn nfc_chars<'a>(&'a self) -> Recompositions<'a> { ... }
fn nfkc_chars<'a>(&'a self) -> Recompositions<'a> { ... }
}Any string that can be represented as a slice.
Required Methods
fn into_string(self) -> String
Converts self into a String, not making a copy if possible.
Provided Methods
fn escape_default(&self) -> String
Escapes each char in s with char::escape_default.
fn escape_unicode(&self) -> String
Escapes each char in s with char::escape_unicode.
fn replace(&self, from: &str, to: &str) -> String
Replaces all occurrences of one string with another.
Arguments
from- The string to replaceto- The replacement string
Return value
The original string with all occurrences of from replaced with to.
Example
fn main() { let s = "Do you know the muffin man, The muffin man, the muffin man, ...".to_string(); assert_eq!(s.replace("muffin man", "little lamb"), "Do you know the little lamb, The little lamb, the little lamb, ...".to_string()); // not found, so no change. assert_eq!(s.replace("cookie monster", "little lamb"), s); }let s = "Do you know the muffin man, The muffin man, the muffin man, ...".to_string(); assert_eq!(s.replace("muffin man", "little lamb"), "Do you know the little lamb, The little lamb, the little lamb, ...".to_string()); // not found, so no change. assert_eq!(s.replace("cookie monster", "little lamb"), s);
fn repeat(&self, nn: uint) -> String
Given a string, makes a new string with repeated copies of it.
fn lev_distance(&self, t: &str) -> uint
Returns the Levenshtein Distance between two strings.
fn nfd_chars<'a>(&'a self) -> Decompositions<'a>
Returns an iterator over the string in Unicode Normalization Form D (canonical decomposition).
fn nfkd_chars<'a>(&'a self) -> Decompositions<'a>
Returns an iterator over the string in Unicode Normalization Form KD (compatibility decomposition).
fn nfc_chars<'a>(&'a self) -> Recompositions<'a>
An Iterator over the string in Unicode Normalization Form C (canonical decomposition followed by canonical composition).
fn nfkc_chars<'a>(&'a self) -> Recompositions<'a>
An Iterator over the string in Unicode Normalization Form KC (compatibility decomposition followed by canonical composition).
Implementors
impl<'a> StrAllocating for MaybeOwned<'a>impl<'a> StrAllocating for &'a strimpl StrAllocating for String