[−][src]Struct alloc_compose::Quantizer
#![feature(allocator_api)] use alloc_compose::Quantizer; use core::mem; use std::alloc::{AllocInit, AllocRef, Global, Layout}; let mut quantizer = Quantizer { allocator: Global, func: |u| u * 2, }; let memory = quantizer.alloc(Layout::new::<u32>(), AllocInit::Uninitialized)?; assert!( memory.size >= mem::size_of::<u32>() * 2, "expected: {}, got: {}", mem::size_of::<u32>() * 2, memory.size, );
Fields
allocator: A
func: F
Trait Implementations
impl<A, F> AllocRef for Quantizer<A, F> where
A: AllocRef,
F: Fn(usize) -> usize,
[src]
A: AllocRef,
F: Fn(usize) -> usize,
fn alloc(
&mut self,
layout: Layout,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
layout: Layout,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout)
[src]
unsafe fn grow(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
placement: ReallocPlacement,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize,
placement: ReallocPlacement,
init: AllocInit
) -> Result<MemoryBlock, AllocErr>
unsafe fn shrink(
&mut self,
_ptr: NonNull<u8>,
_layout: Layout,
_new_size: usize,
_placement: ReallocPlacement
) -> Result<MemoryBlock, AllocErr>
[src]
&mut self,
_ptr: NonNull<u8>,
_layout: Layout,
_new_size: usize,
_placement: ReallocPlacement
) -> Result<MemoryBlock, AllocErr>
fn by_ref(&mut self) -> &mut Self
[src]
Auto Trait Implementations
impl<A, F> Send for Quantizer<A, F> where
A: Send,
F: Send,
A: Send,
F: Send,
impl<A, F> Sync for Quantizer<A, F> where
A: Sync,
F: Sync,
A: Sync,
F: Sync,
impl<A, F> Unpin for Quantizer<A, F> where
A: Unpin,
F: Unpin,
A: Unpin,
F: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,