allocator_api 0.2.0

This is a copy of the unstable allocator_api (https://github.com/rust-lang/rust/issues/32838) and of parts of the unstable alloc feature. Usable with stable rust, but requires 1.25.
Documentation
#![no_std]

pub mod alloc;
pub mod boxed;
pub mod raw_vec;

pub use alloc::*;
pub use boxed::*;
pub use raw_vec::*;

use core::ptr::NonNull;

pub trait NonNullCast {
    fn cast_<U>(self) -> NonNull<U>;
    fn as_opaque_(self) -> NonNull<Opaque>;
}

impl<T: ?Sized> NonNullCast for NonNull<T> {
    fn cast_<U>(self) -> NonNull<U> {
        unsafe {
            NonNull::new_unchecked(self.as_ptr() as *mut U)
        }
    }

    fn as_opaque_(self) -> NonNull<Opaque> {
        self.cast_()
    }
}