Primitive Type str [-] [+]

String manipulation

For more details, see std::str

Trait Implementations

impl Repr<Slice<u8>> for str

fn repr(&self) -> T

impl Ord for str

fn cmp(&self, other: &str) -> Ordering

impl PartialEq for str

fn eq(&self, other: &str) -> bool

fn ne(&self, other: &str) -> bool

impl Eq for str

impl PartialOrd for str

fn partial_cmp(&self, other: &str) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

impl Index<Range<usize>> for str

Returns a slice of the given string from the byte range [begin..end).

This operation is O(1).

Panics when begin and end do not point to valid characters or point beyond the last character of the string.

Example

fn main() { let s = "Löwe 老虎 Léopard"; assert_eq!(&s[0 .. 1], "L"); assert_eq!(&s[1 .. 9], "öwe 老"); // these will panic: // byte 2 lies within `ö`: // &s[2 ..3]; // byte 8 lies within `老` // &s[1 .. 8]; // byte 100 is outside the string // &s[3 .. 100]; }
let s = "Löwe 老虎 Léopard";
assert_eq!(&s[0 .. 1], "L");

assert_eq!(&s[1 .. 9], "öwe 老");

// these will panic:
// byte 2 lies within `ö`:
// &s[2 ..3];

// byte 8 lies within `老`
// &s[1 .. 8];

// byte 100 is outside the string
// &s[3 .. 100];

type Output = str

fn index(&self, index: &Range<usize>) -> &str

impl Index<RangeTo<usize>> for str

Returns a slice of the string from the beginning to byte end.

Equivalent to self[0 .. end].

Panics when end does not point to a valid character, or is out of bounds.

type Output = str

fn index(&self, index: &RangeTo<usize>) -> &str

impl Index<RangeFrom<usize>> for str

Returns a slice of the string from begin to its end.

Equivalent to self[begin .. self.len()].

Panics when begin does not point to a valid character, or is out of bounds.

type Output = str

fn index(&self, index: &RangeFrom<usize>) -> &str

impl Index<RangeFull> for str

type Output = str

fn index(&self, _index: &RangeFull) -> &str

impl Str for str

fn as_slice<'a>(&'a self) -> &'a str

impl StrExt for str

fn contains(&self, needle: &str) -> bool

fn contains_char<P: CharEq>(&self, pat: P) -> bool

fn chars(&self) -> Chars

fn bytes(&self) -> Bytes

fn char_indices(&self) -> CharIndices

fn split<P: CharEq>(&self, pat: P) -> Split<P>

fn splitn<P: CharEq>(&self, count: usize, pat: P) -> SplitN<P>

fn split_terminator<P: CharEq>(&self, pat: P) -> SplitTerminator<P>

fn rsplitn<P: CharEq>(&self, count: usize, pat: P) -> RSplitN<P>

fn match_indices<'a>(&'a self, sep: &'a str) -> MatchIndices<'a>

fn split_str<'a>(&'a self, sep: &'a str) -> SplitStr<'a>

fn lines(&self) -> Lines

fn lines_any(&self) -> LinesAny

fn char_len(&self) -> usize

fn slice_chars(&self, begin: usize, end: usize) -> &str

unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str

fn starts_with(&self, needle: &str) -> bool

fn ends_with(&self, needle: &str) -> bool

fn trim_matches<P: CharEq>(&self, pat: P) -> &str

fn trim_left_matches<P: CharEq>(&self, pat: P) -> &str

fn trim_right_matches<P: CharEq>(&self, pat: P) -> &str

fn is_char_boundary(&self, index: usize) -> bool

fn char_range_at(&self, i: usize) -> CharRange

fn char_range_at_reverse(&self, start: usize) -> CharRange

fn char_at(&self, i: usize) -> char

fn char_at_reverse(&self, i: usize) -> char

fn as_bytes(&self) -> &[u8]

fn find<P: CharEq>(&self, pat: P) -> Option<usize>

fn rfind<P: CharEq>(&self, pat: P) -> Option<usize>

fn find_str(&self, needle: &str) -> Option<usize>

fn slice_shift_char(&self) -> Option<(char, &str)>

fn subslice_offset(&self, inner: &str) -> usize

fn as_ptr(&self) -> *const u8

fn len(&self) -> usize

fn is_empty(&self) -> bool

fn parse<T: FromStr>(&self) -> Result<T, Err>

impl<'a> Default for &'a str

fn default() -> &'a str

impl Hash for str

fn hash<H: Hasher>(&self, state: &mut H)

fn hash_slice<H: Hasher>(data: &[Self], state: &mut H) where Self: Sized

impl Debug for str

fn fmt(&self, f: &mut Formatter) -> Result

impl Display for str

fn fmt(&self, f: &mut Formatter) -> Result