Crate rcsubstring

Crate rcsubstring 

Source
Expand description

A reference-counted substring

For returning part of a string held in an Rc that needs to live longer than the source of the string itself. For a more complete alternative see ArcStr. This is intended as a lightweight alternative where the string is held in an Rc rather than an Arc and in simple single-threaded situations.

§Example

let shared_text: Rc<String> = Rc::new(String::from("Some text"));
let shared_substring = RcSubstring::new(Rc::clone(&shared_text), 5..9);
drop(shared_text);
assert_eq!(shared_substring, "text");

Structs§

RcSubstring
A reference counted substring