pub struct Flat<T: ?Sized, B: Buffer> { /* private fields */ }Expand description
Inline-only storage for ?Sized types.
Stores a trait object (or slice) directly in a buffer of type B.
The total struct size equals size_of::<B>().
- Sized T: full buffer capacity, value at offset 0.
- ?Sized T: one pointer-sized word reserved for metadata, value follows.
Use the flat! macro for ?Sized construction,
or Flat::new for Sized types.
§Compile-time safety
The ?Sized metadata overhead (one pointer-sized word) is validated at compile time
for hand-implemented Buffer types. All predefined
buffers (B16+) satisfy this constraint.
Implementations§
Trait Implementations§
impl<T: ?Sized + Send, B: Buffer> Send for Flat<T, B>
impl<T: ?Sized + Sync, B: Buffer> Sync for Flat<T, B>
Auto Trait Implementations§
impl<T, B> Freeze for Flat<T, B>
impl<T, B> RefUnwindSafe for Flat<T, B>
impl<T, B> Unpin for Flat<T, B>
impl<T, B> UnsafeUnpin for Flat<T, B>where
B: UnsafeUnpin,
T: ?Sized,
impl<T, B> UnwindSafe for Flat<T, B>
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