maybe_null

Crates.iomaybe_null
lib.rsmaybe_null
version
sourcesrc
created_at2024-12-04 01:38:15.369658
updated_at2024-12-04 16:21:15.990027
descriptionA pointer type for handling potentially null values without accidental dereference
homepage
repositoryhttps://github.com/hazelwiss/maybe_null
max_upload_size
id1470896
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
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