Skip to main content

StringOptimizations

Trait StringOptimizations 

Source
pub trait StringOptimizations {
    // Required methods
    fn as_cow(&self) -> CowStr<'_>;
    fn to_shared(&self) -> SharedString;
}
Expand description

Convert common string operations to use Cow to avoid clones

Required Methods§

Source

fn as_cow(&self) -> CowStr<'_>

Get a borrowed or owned string depending on whether modification is needed

Source

fn to_shared(&self) -> SharedString

Share a string across multiple owners without cloning

Implementations on Foreign Types§

Source§

impl StringOptimizations for &str

Source§

impl StringOptimizations for String

Implementors§