Primitive Type str []

String manipulation

For more details, see std::str

Trait Implementations

impl AsRef<str> for str

fn as_ref(&self) -> &str

impl Repr<Slice<u8>> for str

fn repr(&self) -> T

impl<'a, 'b> Pattern<'a> for &'b str

Non-allocating substring search.

Will handle the pattern "" as returning empty matches at each utf8 boundary.

type Searcher = StrSearcher<'a, 'b>

fn into_searcher(self, haystack: &'a str) -> StrSearcher<'a, 'b>

fn is_contained_in(self, haystack: &'a str) -> bool

fn is_prefix_of(self, haystack: &'a str) -> bool

fn is_suffix_of(self, haystack: &'a str) -> bool where Self::Searcher: ReverseSearcher<'a>

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.

Examples

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 AsRef<[u8]> for str

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

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