1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#![no_std]
#![cfg_attr(not(feature = "nonnull_cast"), allow(unstable_name_collision))]
#[path = "libcore/alloc.rs"]
mod core_alloc;
#[path = "libstd/alloc.rs"]
mod std_alloc;
#[path = "liballoc/boxed.rs"]
pub mod boxed;
#[path = "liballoc/raw_vec.rs"]
pub mod raw_vec;
pub mod alloc {
pub use core_alloc::*;
pub use std_alloc::rust_oom as oom;
pub use std_alloc::{set_oom_hook, take_oom_hook};
}
pub use alloc::*;
pub use boxed::*;
pub use raw_vec::*;
#[cfg(not(feature = "nonnull_cast"))]
use core::ptr::NonNull;
#[cfg(not(feature = "nonnull_cast"))]
pub trait NonNullCast {
fn cast<U>(self) -> NonNull<U>;
}
#[cfg(not(feature = "nonnull_cast"))]
impl<T: ?Sized> NonNullCast for NonNull<T> {
fn cast<U>(self) -> NonNull<U> {
unsafe {
NonNull::new_unchecked(self.as_ptr() as *mut U)
}
}
}