Expand description
A UTF-8 encoded, growable string.
The Str
type is string type that has owership over the char.
§Example
You can create a Str
from a literal string with Str::from
:
use str::Str;
let hello = Str::from("hello, world!");
You can append a char
to a Str
with the push
method, and
append a &str
with the push_str
method;
use str::Str;
let mut hello = Str::from("Hello, ");
hello.push('w');
hello.push_str("orld!");
If you have a String
, you can create a Str
from it with the
from
method, and you can convert Str
to String
whit the
into
method:
use str::Str;
let hello = String::from("Hello world!");
let world = Str::from(hello);
let hello_world: String = world.into();
Structs§
- Str
- A UTF-8 encoded, growable string.
- StrIterator