#uninitialized-memory #memory #uninitialized #initialization #maybe-uninit

no-std possibly_uninit

Traits and types helping with using uninitialized memory safely

2 releases

0.1.0 Mar 14, 2021
0.1.0-preview Nov 25, 2019

#1527 in Rust patterns

26 downloads per month

MITNFA license

120KB
2.5K SLoC

Possibly uninitialized

Traits and types helping with using uninitialized memory safely.

About

This crate provides several traits and types that make working with uninitialized memory safer. They avoid memory bugs like accidentally writing uninitialized value into initialized memory, reading uninitialized memory, etc. They also provide strong guarantees for other safe code, which is expressed as unsafe traits.

Since uninitialized values make most sense when it comes to large objects, the main focus is on slices and arrays. For instance, you can initialize Box<[T]> or Box<[T; N]> after it was allocated, avoiding copying. Unfortunately that part isn't quite perfect right now, but it does seem to work correctly.

The crate is no_std-compatible and alloc-compatible, of course.


lib.rs:

Traits and types helping with using uninitialized memory safely.

This crate provides several traits and types that make working with uninitialized memory safer. They avoid memory bugs like accidentally writing uninitialized value into initialized memory, reading uninitialized memory, etc. They also provide strong guarantees for other safe code, which is expressed as unsafe traits.

Since uninitialized values make most sense when it comes to large objects, the main focus is on slices and arrays. For instance, you can initialize Box<[T]> or Box<[T; N]> after it was allocated, avoiding copying. Unfortunately that part isn't quite perfect right now, but it does seem to work correctly.

The crate is no_std-compatible and alloc-compatible, of course.

No runtime deps

Features