4 releases (2 breaking)

new 0.3.1 Apr 12, 2025
0.3.0 Apr 12, 2025
0.2.0 Mar 6, 2023
0.1.0 Mar 6, 2023

#700 in Rust patterns

Download history 1/week @ 2024-12-22 1/week @ 2024-12-29 4/week @ 2025-01-05 13/week @ 2025-01-12 14/week @ 2025-01-19 5/week @ 2025-01-26 17/week @ 2025-02-02 36/week @ 2025-02-09 12/week @ 2025-02-16 8/week @ 2025-02-23 13/week @ 2025-03-02 15/week @ 2025-03-09 13/week @ 2025-03-16 13/week @ 2025-03-23 9/week @ 2025-03-30 66/week @ 2025-04-06

111 downloads per month
Used in 7 crates (2 directly)

MIT/Apache

20KB
115 lines

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 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.

No runtime deps

Features