1.0.0[−][src]Module alloc::str
Unicode string slices.
See also the str primitive type.
The &str type is one of the two main string types, the other being String.
Unlike its String counterpart, its contents are borrowed.
Basic Usage
A basic string declaration of &str type:
let hello_world = "Hello, World!";Run
Here we have declared a string literal, also known as a string slice.
String literals have a static lifetime, which means the string hello_world
is guaranteed to be valid for the duration of the entire program.
We can explicitly specify hello_world's lifetime as well:
let hello_world: &'static str = "Hello, world!";Run
Modules
| pattern | Experimental |
Structs
Traits
| FromStr |
Functions
| from_boxed_utf8_unchecked⚠ | Converts a boxed slice of bytes to a boxed string slice without checking that the string contains valid UTF-8. |
| from_utf8 | |
| from_utf8_mut | |
| from_utf8_unchecked⚠ | |
| from_utf8_unchecked_mut⚠ |