pub struct RcStrInterning { /* private fields */ }Expand description
Runtime string interning table.
Deduplicates strings by storing them in an FxHashSet<RcStr>. Strings
shorter than the inline threshold are already zero-allocation, so only
longer strings benefit from interning.
Implementations§
Source§impl RcStrInterning
impl RcStrInterning
Sourcepub fn intern(&mut self, s: &str) -> RcStr
pub fn intern(&mut self, s: &str) -> RcStr
Intern a string slice. Returns a cheap-to-clone RcStr.
Strings below the inline threshold are returned directly (they are already zero-allocation inline atoms). Longer strings are looked up in the interning table and deduplicated.
Sourcepub fn intern_cow(&mut self, s: Cow<'_, str>) -> RcStr
pub fn intern_cow(&mut self, s: Cow<'_, str>) -> RcStr
Intern a Cow<str>. When the cow is Owned, avoids an extra copy
if the string is not yet interned.
Sourcepub fn intern_display(&mut self, v: &impl Display) -> RcStr
pub fn intern_display(&mut self, v: &impl Display) -> RcStr
Intern the Display output of a value.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RcStrInterning
impl RefUnwindSafe for RcStrInterning
impl Send for RcStrInterning
impl Sync for RcStrInterning
impl Unpin for RcStrInterning
impl UnsafeUnpin for RcStrInterning
impl UnwindSafe for RcStrInterning
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.