Closed
Description
ptr::NonNull<T>
is similar to *mut T
. Its cast
method added in #47631 is similar to raw pointer casting with the as
operator.
impl<T: ?Sized> NonNull<T> {
pub fn cast<U>(self) -> NonNull<U> {
unsafe {
NonNull::new_unchecked(self.as_ptr() as *mut U)
}
}
}
Note that T
is ?Sized
but U
is not (or we’d get a E0606 "vtable kinds may not match" error on as
)
Metadata
Metadata
Assignees
Labels
Blocker: Implemented in the nightly compiler and unstable.Category: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the library API team, which will review and decide on the PR/issue.In the final comment period and will be merged soon unless new substantive objections are raised.