pub struct Str { /* private fields */ }Implementations§
source§impl Str
impl Str
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this Str has a length of 0, and false otherwise.
sourcepub fn char_at(&self, index: i32) -> Option<char>
pub fn char_at(&self, index: i32) -> Option<char>
Extracts the ith character of the string. Index can be negative, like Python’s str: str[-1] gets the last element.
sourcepub fn find(&self, pattern: &str) -> Option<usize>
pub fn find(&self, pattern: &str) -> Option<usize>
Returns the byte index of the first character of this string that matches the pattern.
sourcepub fn contains(&self, pattern: &str) -> bool
pub fn contains(&self, pattern: &str) -> bool
Returns true if the given pattern matches a sub-slice of this string.
sourcepub fn count(&self, element: char) -> usize
pub fn count(&self, element: char) -> usize
Count the total number of occurrences of the specified element in the string.
sourcepub fn to_decimal(&self) -> Option<f64>
pub fn to_decimal(&self) -> Option<f64>
Convert the string to a double-precision floating-point decimal number.
sourcepub fn starts_with(&self, pattern: &str) -> bool
pub fn starts_with(&self, pattern: &str) -> bool
Return true if the string starts with the specified string, otherwise return false.
sourcepub fn ends_with(&self, pattern: &str) -> bool
pub fn ends_with(&self, pattern: &str) -> bool
Return true if the string ends with the specified string, otherwise return false.
Trait Implementations§
source§impl FromIterator<char> for Str
impl FromIterator<char> for Str
source§impl Ord for Str
impl Ord for Str
source§impl PartialOrd for Str
impl PartialOrd for Str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Eq for Str
impl StructuralPartialEq for Str
Auto Trait Implementations§
impl Freeze for Str
impl RefUnwindSafe for Str
impl Send for Str
impl Sync for Str
impl Unpin for Str
impl UnwindSafe for Str
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more