constptr

Crates.ioconstptr
lib.rsconstptr
version0.2.0
sourcesrc
created_at2023-03-06 15:33:11.562295
updated_at2023-03-06 19:25:45.415288
descriptionNonNull without mutability
homepage
repositoryhttps://git.pipapo.org/cehteh/constptr.git
max_upload_size
id802716
size19,173
(cehteh)

documentation

README

ConstPtr

Rusts std::ptr::NonNull wraps a *mut pointer. Sometimes this has implications that are not desired. ConstPtr wraps NullPtr but removes the mutable and uninit API's. As consequence it can only be constructed to point to a valid object (although it may become dangling when the object becomes destroyed). This simplifies handling lifetime erased references because a &reference implicitly coerces to a *const pointer and adds some safety net as in one can't accidentally get a mutable reference to something that should been const.

'nostd' compatibility

By default the 'std' feature is enabled which pulls in dependencies on rusts stdlib. When one disables this in 'default' then ConstPtr becomes no-std compatible.

Commit count: 0

cargo fmt