by ridiculous_fish · 5y ago · 0 comments
Is there any analog for a const pointer? I want to point into or just beyond a const array, intrusively using null as a None value.
There is `ptr::NonNull` but this always converts to a *mut T, and one is just supposed to "be careful" to not use the mutable features if your pointee isn't actually mutable.
If you look at the implementation of slice::Iter, it stores a (cursor, end) pointer pair, but there's no way to say "this is a non-null const pointer" so it casts the cursor pointer to *mut.