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
45
46
47
//! # allocdeny
//!
//! Deny the use of crate `alloc`.
//!
//! This crate exists solely to deny the use of the built-in `alloc` crate.
//! This is useful if your library has different safety/soundness requirements
//! than those allowed by Rust's own `alloc`.
//!
//! # Examples
//!
//! The following code only compiles with this crate:
//!
//! ```rust
//! extern crate alloc;
//! alloc::allocdeny!();
//! ```
//!
//! When doing this, regular alloc is inaccessible.
//!
//! # Usage
//!
//! Library authors who are doing their own thing and not relying on fn main()
//! can simply expand this macro in their entry point wrapper. For example:
//!
//! ```rust
//! macro_rules! my_plugin {
//! () => {
//! alloc::allocdeny!();
//! extern "C" fn plugin_init() {
//! }
//! }
//! }
//! ```
//!
//! Then users of `my_plugin!` will be unable to use `alloc`!
//! You can also provide an `unsafe` version of `my_plugin` that does not expand
//! `alloc::allocdeny!()`, if you want.