/// Aligns the internal buffer to the given alignment.
///
/// # Panics
///
/// `align` must be a power of two.
Aligns the internal buffer to the given alignment.
Aligns the internal buffer to the given alignment .
fn align_to(&self, align: usize) -> Result<(), OutOfMemory> {
        assert!(align.is_power_of_two());
        // SAFE: see the safety notes in alloc_raw().
        let current_addr =
            unsafe { self.buf_ptr.as_ptr().add(self.cursor.get()) as usize };
        let aligned = align_to(current_addr, align);
        if aligned == usize::MAX && align > 1 {
            // We've hit the top of the address space, so we have no hope of
            // allocating aligned memory.
            return Err(OutOfMemory);
        }
        let misalignment = aligned - current_addr;
        self.alloc_raw(misalignment)?;
        Ok(())
    }
fn align_to ( & self , align : usize ) -> Result < ( ) , OutOfMemory > { assert ! ( align is_power_of_two ( ) ) ; // SAFE: see the safety notes in alloc_raw(). let current_addr = unsafe { self . buf_ptr . as_ptr ( ) . add ( self . cursor . get ( ) ) as usize } ; let aligned = align_to ( current_addr , align ) ; if aligned == usize :: MAX && align > 1 { // We've hit the top of the address space, so we have no hope of // allocating aligned memory. return Err ( OutOfMemory ) ; } let misalignment = aligned - current_addr ; self . alloc_raw ( misalignment ) ? ; Ok ( ( ) ) }
Aligns the internal buffer to the given alignment.
Aligns the internal buffer to the given alignment .
&self
align
usize
panics
`align` must be a power of two.
` align ` must be a power of two .