Split a string without another allocation
Helpfull for some types that need to be parsed from a string
and get split into smaller parts like an Url
or a Vec
containing lines
which need to be owned by the parent type.
First try to store references, for example &str
which is more efficient.
``rust
use shared_string::SharedString;
// or SharedSyncString if
Sync` is required
struct Name { firstname: SharedString, lastname: SharedString }
impl Name {
pub fn new( fullname: impl Into
let name = Name::new("Albert Einstein").unwrap(); asserteq!( name.firstname, "Albert" ); asserteq!( name.lastname, "Einstein" ); ```