[][src]Struct alloc_compose::Quantizer

pub struct Quantizer<A, F> {
    pub allocator: A,
    pub func: F,
}
#![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: Afunc: F

Trait Implementations

impl<A, F> AllocRef for Quantizer<A, F> where
    A: AllocRef,
    F: Fn(usize) -> usize, 
[src]

Auto Trait Implementations

impl<A, F> Send for Quantizer<A, F> where
    A: Send,
    F: Send

impl<A, F> Sync for Quantizer<A, F> where
    A: Sync,
    F: Sync

impl<A, F> Unpin for Quantizer<A, F> where
    A: Unpin,
    F: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.