1 unstable release

0.1.0 May 17, 2021

#13 in #safely

Download history 6/week @ 2024-07-22 26/week @ 2024-07-29 14/week @ 2024-08-05 5/week @ 2024-08-12 12/week @ 2024-08-19 33/week @ 2024-08-26 34/week @ 2024-09-02 56/week @ 2024-09-09 231/week @ 2024-09-16 102/week @ 2024-09-23 24/week @ 2024-09-30 20/week @ 2024-10-07 21/week @ 2024-10-14 15/week @ 2024-10-21 14/week @ 2024-10-28 25/week @ 2024-11-04

77 downloads per month
Used in 5 crates (3 directly)

Apache-2.0 OR MIT

14KB
360 lines

detached-str

Safely borrow strings without a lifetime.

Documentation

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

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.

No runtime deps