Allocate memory at compile time!

Overview

const-alloc

Link to the docs!

Allocate memory at compile time!

Currently, in stable rust there is no way to dynamically allocate or deallocate memory at compile time (i.e. in const fns). This crate allows you to do exactly that, in nightly rust, with the help of a few intrinsics and a lot of unstable features, so don't be surprised if it suddenly breaks, and please don't use it in production yet.

The crate exposes one type, ConstAlloc, which wraps any allocator and itself implements const Allocator. Using this type you can allocate and deallocate memory in const fns, which would theoretically also allow you to use something like Box or Vec in const contexts. Unfortunately, none of the relevant member functions on those types are const yet though, so unfortunately it's still not really possible (yet?) to use any standard library collection at compile time.

License: Apache-2.0 OR MIT

You might also like...
๐ŸŒ‹ A very lightweight wrapper around the Vulkan Memory Allocator ๐Ÿฆ€

๐ŸŒ‹ vk-mem-alloc-rs A very lightweight wrapper around the Vulkan Memory Allocator ๐Ÿฆ€ [dependencies] vk-mem-alloc = "0.1.1" Simple Vulkan Memory Allocat

Hide memory artifacts using ROP and hardware breakpoints.
Hide memory artifacts using ROP and hardware breakpoints.

Description This tool is a simple PoC of how to hide memory artifacts using a ROP chain in combination with hardware breakpoints. The ROP chain will c

Executable memory allocator with support for dual mapping and W^X protection

jit-allocator A simple memory allocator for executable code. Use JitAllocator type to allocate/release memory and virtual_memory module functions to e

Memory.lol - a tiny web service that provides historical information about social media accounts

memory.lol Overview This project is a tiny web service that provides historical information about social media accounts. It can currently be used to l

This is a Telegram bot I'm working on in my free time to learn Rust.

Maldness Bot This is a Telegram bot I'm working on in my free time to learn Rust. Building docker build -t . should be enough.

Rust bindings for the KING OF TIME API

Rust bindings for the KING OF TIME API Example Prints if you are at work or not at work. $ cargo run --example tc -- status Record the time you start

A library to access BGPKIT Broker API and enable searching for BGP data archive files over time from public available data sources.
A library to access BGPKIT Broker API and enable searching for BGP data archive files over time from public available data sources.

BGPKIT Broker BGPKIT Broker is a online data API service that allows users to search for publicly available BGP archive files by time, collector, proj

Building a better screen reader for the Linux desktop, one step at a time.

Building a better screen reader for the Linux desktop, one step at a time.

NSE is a rust cli binary and library for extracting real-time data from National Stock Exchange (India)

NSE Check out the sister projects NsePython and SaveKiteEnctoken which are Python & Javascript libraries to use the NSE and Zerodha APIs respectively

Owner
Sp00ph
Sp00ph
Faster division by constants that aren't known at compile-time

Baseline implementation of division by constants When dividing integers by compile-time constants, compilers (LLVM) can be trusted to convert those to

Paul Khuong 18 Jul 6, 2022
This crate defines a single macro that is a brainfunct compile-time interpreter.

Compile Protection This crate defines a single macro that is a brainfunct compile-time interpreter. One example is as follows #![recursion_limit = "18

John Marsden 7 Nov 29, 2021
constduck: compile-time duck typing and reflection

constduck provides a procmacro that can enable compile time duck typing and reflection on arbitrary struct types.

ferrouille 15 Oct 12, 2022
Option and Either types with variants known at compile time.

Const Either Some types to allow deciding at compile time if an option contains a value or which variant from the either type is active. This might be

null 1 May 5, 2022
Compile-time lifetimes for comments.

todo_by Compile-time lifetimes for comments. To use this macro, add it to your dependencies via Cargo: cargo add todo_by Then, import and invoke the m

Parker McMullin 116 May 23, 2023
A Rust proc-macro crate which derives functions to compile and parse back enums and structs to and from a bytecode representation

Bytecode A simple way to derive bytecode for you Enums and Structs. What is this This is a crate that provides a proc macro which will derive bytecode

null 4 Sep 3, 2022
little brother of gnu-copypasta-maker To compile, use make.

UWU Maker little brother of gnu-copypasta-maker To compile, use make. To install, use sudo make install or if you are root make install To uninstall,

Ahmet Efe AKYAZI 1 Jan 12, 2022
Traits for inspecting memory usage of Rust types

memuse This crate contains traits for measuring the dynamic memory usage of Rust types. About Memory-tracking is a common activity in large applicatio

null 13 Dec 23, 2022
secmem-proc is a crate designed to harden a process against low-privileged attackers running on the same system trying to obtain secret memory contents of the current process.

secmem-proc is a crate designed to harden a process against low-privileged attackers running on the same system trying to obtain secret memory contents of the current process. More specifically, the crate disables core dumps and tries to disable tracing on unix-like OSes.

null 3 Dec 19, 2022
๐Ÿฆ€๐Ÿš€๐Ÿ”ฅ A blazingly fast and memory-efficient implementation of `if err != nil` ๐Ÿ”ฅ๐Ÿš€๐Ÿฆ€

?????? A blazingly fast and memory-efficient implementation of `if err != nil` ??????

Federico Damiรกn Schonborn 6 Dec 30, 2022