Crate detached_str[][src]

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 a StrSlice.

StrSlice

A memory efficient string slice without a lifetime.

Traits

StrSliceIndex

Trait for indexing a StrSlice (using the StrSlice::get method)