Expand description
A crate for borrowing strings without a lifetime.
§Example
use detached_str::{Str, StrSlice};
let string: Str = "Hello, world!".into();
let slice: StrSlice = string.get(7..);
assert_eq!(slice.to_str(&string), "world!");
A StrSlice
is “detached”, i.e. the string content can only be accessed
when you have a reference to the owned string. The owned string is immutable
to ensure that string slices remain valid.
Structs§
- Str
- An immutable string. It dereferences to a
&str
and can also be borrowed as aStrSlice
. - StrSlice
- A memory efficient string slice without a lifetime.
Traits§
- StrSlice
Index - Trait for indexing a
StrSlice
(using theStrSlice::get
method)