Module std::strStable
[-] [+]
[src]
Unicode string manipulation (the str type).
Rust's str type is one of the core primitive types of the language. &str
is the borrowed string type. This type of string can only be created from
other strings, unless it is a &'static str (see below). It is not possible
to move out of borrowed strings because they are owned elsewhere.
Examples
Here's some code that uses a &str:
let s = "Hello, world.";
This &str is a &'static str, which is the type of string literals.
They're 'static because literals are available for the entire lifetime of
the program.
You can get a non-'static &str by taking a slice of a String:
let s = &some_string;
Representation
Rust's string type, str, is a sequence of Unicode scalar values encoded as
a stream of UTF-8 bytes. All strings are
guaranteed to be validly encoded UTF-8 sequences. Additionally, strings are
not null-terminated and can thus contain null bytes.
The actual representation of strs have direct mappings to slices: &str
is the same as &[u8].
Modules
| pattern | The string Pattern API. |
Structs
| Bytes | External iterator for a string's bytes.
Use with the |
| CharIndices | Iterator for a string's characters and their byte offsets. |
| CharRange | Struct that contains a |
| Chars | Iterator for the char (representing Unicode Scalar Values) of a string |
| Decompositions | External iterator for a string decomposition's characters. |
| GraphemeIndices | External iterator for grapheme clusters and byte offsets. |
| Graphemes | External iterator for a string's grapheme clusters. |
| Lines | Created with the method |
| LinesAny | Created with the method |
| MatchIndices | /// Created with the method |
| Matches | /// Created with the method |
| ParseBoolError | An error returned when parsing a |
| RMatchIndices | /// Created with the method |
| RMatches | /// Created with the method |
| RSplit | /// Created with the method |
| RSplitN | /// Created with the method |
| RSplitTerminator | /// Created with the method |
| Recompositions | External iterator for a string recomposition's characters. |
| Split | /// Created with the method |
| SplitN | /// Created with the method |
| SplitTerminator | /// Created with the method |
| Utf16Units | External iterator for a string's UTF16 codeunits. |
| Utf8Error | Errors which can occur when attempting to interpret a byte slice as a |
| Words | An iterator over the words of a string, separated by a sequence of whitespace |
Traits
| FromStr | A trait to abstract the idea of creating a new instance of a type from a string. |
Functions
| from_utf8 | Converts a slice of bytes to a string slice without performing any allocations. |
| from_utf8_unchecked | Converts a slice of bytes to a string slice without checking that the string contains valid UTF-8. |