pub fn allocate(&self, amount: usize) -> Option<Memory<'heap>> {
        let s = self.as_mut();
        s.ptr.and_then(|block| {
            if amount > block.size {
                None
            } else if block.size - amount < FREE_BLOCK_SIZE {
                // if there isn't enough left in this block for a new block, just use it all.
                s.ptr = block.next.ptr;
                Some(block.as_memory())
            } else {
                // split off a new alloc
                let (a1, a2) = block.as_memory().split_at(amount);
                s.ptr = Some(FreeBlock::from_memory(a2, block.next));
                Some(a1)
            }
        })
    }
// attempt to allocate memory out of this block.
attempt to allocate memory out of this block.
attempt to allocate memory out of this block .
pub fn allocate(&self, amount: usize) -> Option<Memory<'heap>> {
        let s = self.as_mut();
        s.ptr.and_then(|block| {
            if amount > block.size {
                None
            } else if block.size - amount < FREE_BLOCK_SIZE {
                // if there isn't enough left in this block for a new block, just use it all.
                s.ptr = block.next.ptr;
                Some(block.as_memory())
            } else {
                // split off a new alloc
                let (a1, a2) = block.as_memory().split_at(amount);
                s.ptr = Some(FreeBlock::from_memory(a2, block.next));
                Some(a1)
            }
        })
    }
pub fn allocate ( & self , amount : usize ) -> Option < Memory < ' heap > > { let s = self . as_mut ( ) ; s . ptr . and_then ( | block | { if amount > block . size { None } else if block . size - amount < FREE_BLOCK_SIZE { // if there isn't enough left in this block for a new block, just use it all. s . ptr = block . next . ptr ; Some ( block . as_memory ( ) ) } else { // split off a new alloc let ( a1 , a2 ) = block . as_memory ( ) . split_at ( amount ) ; s . ptr = Some ( FreeBlock :: from_memory ( a2 , block . next ) ) ; Some ( a1 ) } } ) }
attempt to allocate memory out of this block.
attempt to allocate memory out of this block .
&self
amount
usize
&self
amount
usize