allocdeny 0.1.0

Deny the use of crate `alloc`
Documentation
  • Coverage
  • 33.33%
    1 out of 3 items documented1 out of 1 items with examples
  • Size
  • Source code size: 2.61 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.08 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • SoniEx2

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:

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:

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.