pub struct SpanAllocator<C> { /* private fields */ }Expand description
Reusable color buffer for span generators.
Allocates and reuses a buffer of color values. The buffer grows as needed (aligned to 256 elements) but never shrinks, avoiding repeated allocations during rendering.
Port of C++ span_allocator<ColorT>.
Implementations§
Source§impl<C: Default + Clone> SpanAllocator<C>
impl<C: Default + Clone> SpanAllocator<C>
pub fn new() -> Self
Sourcepub fn allocate(&mut self, span_len: usize) -> &mut [C]
pub fn allocate(&mut self, span_len: usize) -> &mut [C]
Allocate (or reuse) a buffer of at least span_len elements.
Returns a mutable slice of exactly span_len elements.
The buffer may be larger internally (aligned to 256).
pub fn span(&mut self) -> &mut [C]
pub fn max_span_len(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl<C> Freeze for SpanAllocator<C>
impl<C> RefUnwindSafe for SpanAllocator<C>where
C: RefUnwindSafe,
impl<C> Send for SpanAllocator<C>where
C: Send,
impl<C> Sync for SpanAllocator<C>where
C: Sync,
impl<C> Unpin for SpanAllocator<C>where
C: Unpin,
impl<C> UnwindSafe for SpanAllocator<C>where
C: UnwindSafe,
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