pub const fn from_ref<T: ?Sized>(reff: &T) -> NonNull<T>
Expand description
Const equivalent of
<NonNull<T> as From<&T>>::from
ยงExample
use konst::ptr::nonnull;
use core::ptr::NonNull;
const H: NonNull<str> = nonnull::from_ref("hello");
const W: NonNull<str> = nonnull::from_ref("world");
unsafe{
assert_eq!(H.as_ref(), "hello");
assert_eq!(W.as_ref(), "world");
}