pub struct Compact;Expand description
A compact string representation equal to String in size with guaranteed inlining.
This representation relies on pointer alignment to be able to store a discriminant bit in its
inline form that will never be present in its String form, thus
giving us 24 bytes on 64-bit architectures, and 12 bytes on 32-bit, minus one bit, to encode our
inline string. It uses the rest of the discriminant bit’s byte to encode the string length, and
the remaining bytes (23 or 11 depending on arch) to store the string data. When the available space is exceeded,
it swaps itself out with a String containing its previous
contents, relying on the discriminant bit in the String’s pointer to be unset, so we can
store the String safely without taking up any extra space for a discriminant.
This performs generally as well as String on all ops on boxed strings, and
better than Strings on inlined strings.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Compact
impl RefUnwindSafe for Compact
impl Send for Compact
impl Sync for Compact
impl Unpin for Compact
impl UnwindSafe for Compact
Blanket Implementations§
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
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 0 bytes