1 unstable release

0.1.0 May 17, 2021

#27 in #safely

Download history 15/week @ 2024-03-11 21/week @ 2024-03-18 25/week @ 2024-03-25 49/week @ 2024-04-01 14/week @ 2024-04-08 16/week @ 2024-04-15 14/week @ 2024-04-22 13/week @ 2024-04-29 14/week @ 2024-05-06 15/week @ 2024-05-13 15/week @ 2024-05-20 9/week @ 2024-05-27 16/week @ 2024-06-03 14/week @ 2024-06-10 7/week @ 2024-06-17 16/week @ 2024-06-24

54 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