maybe_null

Crates.iomaybe_null
lib.rsmaybe_null
version0.2.0
created_at2024-12-04 01:38:15.369658+00
updated_at2024-12-04 16:21:15.990027+00
descriptionA pointer type for handling potentially null values without accidental dereference
homepage
repositoryhttps://github.com/hazelwiss/maybe_null
max_upload_size
id1470896
size14,301
hazelwiss (hazelwiss)

documentation

README

MaybeNull

The MaybeNull type is used for hinting that a pointer may be null, and still prevent accidental null pointer dereference.

use maybe_null::MaybeNull;

let ptr = MaybeNull::<u32>::null();

let Some(ptr) = ptr.get() {
  // We know the pointer is non-null here.

  // Whoops! this will never happen because our `ptr` was initialized as null!
  ptr.write(0);
}

AtomicMaybeNull

The AtomicMaybeNull works like MaybeNull but allows for atomic access of the pointer.

Commit count: 8

cargo fmt