Imstr

In Rust, you can cheaply get slices of string.

#![allow(unused)]
fn main() {
let string = String::from("Hello");
let slice = &string[0..1];
}

You can also use reference counting to cheaply copy strings around, for example when you use multi-threaded async applications.

#![allow(unused)]
fn main() {
let string = Arc::new(String::from("Hello"));
let copy = string.clone();
}

However, when you create a slice of a string, it has a lifetime attached to it. This means that you cannot simply move this to another thread, as there is no guarantee that the string will continue existing (for example, if your current thread panics, it might be deallocated while the other thread is still accessing it).

Unfortunately, Rust has no built-in way to get an owned slice of an a string in an Arc container.

This is where imstr comes in: it is an immutable string, that allows you to cheaply create substrings from it. The substrings you create from it are still owned and can be safely passed around to other threads.

You can find the documentation for imstr here.