pub struct RawInterned<T: ?Sized = Prv>(/* private fields */);Expand description
A same type with the Interned, but with erased lifetime.
Although lifetime is erased, RawInterned still has type, so it can be used when type is
required. You can also erase type too by calling to erase.
§Note
RawInterned is just pointer type and points to the type T in memory. If T is ZST or DST
but containing no data like empty string, the pointer would be non-null, well-aligned, but
dangling. So it’s discouraged to compare type erased RawInterneds because they would have the
same dangling pointers even though they were different types.
Implementations§
Source§impl<T: ?Sized> RawInterned<T>
impl<T: ?Sized> RawInterned<T>
pub fn cast<U>(self) -> RawInterned<U>
pub fn erase(self) -> RawInterned
Methods from Deref<Target = NonNull<T>>§
1.25.0 · Sourcepub unsafe fn as_ref<'a>(&self) -> &'a T
pub unsafe fn as_ref<'a>(&self) -> &'a T
Returns a shared reference to the value. If the value may be uninitialized, as_uninit_ref
must be used instead.
For the mutable counterpart see as_mut.
§Safety
When calling this method, you have to ensure that the pointer is convertible to a reference.
§Examples
use std::ptr::NonNull;
let mut x = 0u32;
let ptr = NonNull::new(&mut x as *mut _).expect("ptr is null!");
let ref_x = unsafe { ptr.as_ref() };
println!("{ref_x}");Trait Implementations§
Source§impl<T: ?Sized> Clone for RawInterned<T>
impl<T: ?Sized> Clone for RawInterned<T>
Source§impl<T: ?Sized> Debug for RawInterned<T>
impl<T: ?Sized> Debug for RawInterned<T>
Source§impl<T: ?Sized> Deref for RawInterned<T>
impl<T: ?Sized> Deref for RawInterned<T>
Source§impl<T: ?Sized> Hash for RawInterned<T>
impl<T: ?Sized> Hash for RawInterned<T>
Source§impl<T: ?Sized> Ord for RawInterned<T>
Pointer comparison by address.
impl<T: ?Sized> Ord for RawInterned<T>
Pointer comparison by address.
Source§impl<T: ?Sized> PartialEq for RawInterned<T>
Pointer comparison by address.
impl<T: ?Sized> PartialEq for RawInterned<T>
Pointer comparison by address.
Source§impl<T: ?Sized> PartialOrd for RawInterned<T>
Pointer comparison by address.
impl<T: ?Sized> PartialOrd for RawInterned<T>
Pointer comparison by address.
impl<T: ?Sized> Copy for RawInterned<T>
impl<T: ?Sized> Eq for RawInterned<T>
Pointer comparison by address.
Auto Trait Implementations§
impl<T> Freeze for RawInterned<T>where
T: ?Sized,
impl<T> RefUnwindSafe for RawInterned<T>where
T: RefUnwindSafe + ?Sized,
impl<T = Prv> !Send for RawInterned<T>
impl<T = Prv> !Sync for RawInterned<T>
impl<T> Unpin for RawInterned<T>where
T: ?Sized,
impl<T> UnwindSafe for RawInterned<T>where
T: RefUnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.