#[repr(C, u8)]pub enum BoxOrStatic<T> {
Boxed(*mut T),
Static(*const T),
}Expand description
A value that is either heap-allocated (parsed at runtime) or a compile-time static reference. Used to reduce enum size for large CSS property payloads by storing them behind a pointer instead of inline.
- Size: 1 (tag) + 7 (padding) + 8 (pointer) = 16 bytes on 64-bit
Staticvariant: no allocation, just a*const Tpointer to static dataBoxedvariant: heap-allocated viaBox::into_raw, freed on Drop
Variants§
Boxed(*mut T)
Heap-allocated (parsed at runtime). Owned — freed on Drop.
Static(*const T)
Compile-time constant (e.g. from const CSS defaults). Not freed.
Implementations§
Trait Implementations§
Source§impl<T: Clone> Clone for BoxOrStatic<T>
impl<T: Clone> Clone for BoxOrStatic<T>
Source§impl<T: Debug> Debug for BoxOrStatic<T>
impl<T: Debug> Debug for BoxOrStatic<T>
Source§impl<T: Default> Default for BoxOrStatic<T>
impl<T: Default> Default for BoxOrStatic<T>
Source§impl<T> Deref for BoxOrStatic<T>
impl<T> Deref for BoxOrStatic<T>
Source§impl<T: Display> Display for BoxOrStatic<T>
impl<T: Display> Display for BoxOrStatic<T>
Source§impl<T> Drop for BoxOrStatic<T>
impl<T> Drop for BoxOrStatic<T>
Source§impl<T: FormatAsRustCode + 'static> FormatAsRustCode for BoxOrStatic<T>
impl<T: FormatAsRustCode + 'static> FormatAsRustCode for BoxOrStatic<T>
fn format_as_rust_code(&self, tabs: usize) -> String
Source§impl<T: Hash> Hash for BoxOrStatic<T>
impl<T: Hash> Hash for BoxOrStatic<T>
Source§impl<T: Ord> Ord for BoxOrStatic<T>
impl<T: Ord> Ord for BoxOrStatic<T>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialEq> PartialEq for BoxOrStatic<T>
impl<T: PartialEq> PartialEq for BoxOrStatic<T>
Source§impl<T: PartialOrd> PartialOrd for BoxOrStatic<T>
impl<T: PartialOrd> PartialOrd for BoxOrStatic<T>
Source§impl<T: PrintAsCssValue> PrintAsCssValue for BoxOrStatic<T>
impl<T: PrintAsCssValue> PrintAsCssValue for BoxOrStatic<T>
fn print_as_css_value(&self) -> String
impl<T: Eq> Eq for BoxOrStatic<T>
impl<T: Send + 'static> Send for BoxOrStatic<T>
impl<T: Sync + 'static> Sync for BoxOrStatic<T>
Auto Trait Implementations§
impl<T> Freeze for BoxOrStatic<T>
impl<T> RefUnwindSafe for BoxOrStatic<T>where
T: RefUnwindSafe,
impl<T> Unpin for BoxOrStatic<T>
impl<T> UnsafeUnpin for BoxOrStatic<T>
impl<T> UnwindSafe for BoxOrStatic<T>where
T: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more