File: README.md

package info (click to toggle)
rust-alloca 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 128 kB
  • sloc: ansic: 13; makefile: 4
file content (22 lines) | stat: -rw-r--r-- 794 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
### alloca-rs

[![Build Status](https://github.com/playXE/alloca-rs/workflows/CI/badge.svg)](https://github.com/playXE/alloca-rs/actions)
[![Latest Version](https://img.shields.io/crates/v/alloca.svg)](https://crates.io/crates/alloca)
[![Documentation](https://docs.rs/alloca/badge.svg)](https://docs.rs/alloca/)

Mostly safe no_std wrapper for `alloca` in Rust.

This crate uses Rust lifetime system to ensure that stack allocated memory will not be used after function return, but
it does not make any guarantee about memory that is turned into raw pointer and stored somewhere else.

### Example

```rust
fn main() {
    // allocate 128 bytes on the stack
    alloca::with_alloca(128, |memory| {
        // memory: &mut [MaybeUninit<u8>]
        assert_eq!(memory.len(), 128);
    });
}
```