2 unstable releases

0.2.0 Mar 6, 2023
0.1.0 Mar 6, 2023

#2983 in Rust patterns

Download history 7/week @ 2023-12-13 16/week @ 2023-12-20 4/week @ 2023-12-27 2/week @ 2024-01-03 13/week @ 2024-01-10 11/week @ 2024-01-17 7/week @ 2024-01-24 2/week @ 2024-02-07 15/week @ 2024-02-14 42/week @ 2024-02-21 26/week @ 2024-02-28 20/week @ 2024-03-06 24/week @ 2024-03-13 37/week @ 2024-03-20 29/week @ 2024-03-27

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

MIT/Apache

19KB
107 lines

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.

No runtime deps

Features