Crates.io | constptr |
lib.rs | constptr |
version | 0.3.1 |
created_at | 2023-03-06 15:33:11.562295+00 |
updated_at | 2025-04-12 21:36:54.61325+00 |
description | NonNull without mutability |
homepage | |
repository | https://git.pipapo.org/cehteh/constptr.git |
max_upload_size | |
id | 802716 |
size | 19,568 |
ConstPtr
Rusts std::ptr::NonNull
is a mutable 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 be const.
no_std
compatibilityBy 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.