pub struct TinyPtr<T>(/* private fields */);Expand description
A tiny pointer to a mutable value of type T. As with all types of this crate, memory is allocated on the heap.
use tinypointers::TinyPtr;
let x = TinyPtr::new(42);
println!("{}", unsafe { *x.get() }); // prints 42Implementations§
Source§impl<T> TinyPtr<T>
impl<T> TinyPtr<T>
pub fn as_ptr(&self) -> *const T
pub fn as_mut_ptr(&mut self) -> *mut T
pub unsafe fn get<'a, 'b>(&'b self) -> &'a T
pub unsafe fn get_mut<'a, 'b>(&'b mut self) -> &'a mut T
Sourcepub fn take(self) -> T
pub fn take(self) -> T
Takes ownership of the value and returns it.
The underlying memory is freed.
Sourcepub fn id(&self) -> NonZeroU16
pub fn id(&self) -> NonZeroU16
Returns the internal id of the pointer.
This is used for debugging purposes.
Trait Implementations§
impl<T> Copy for TinyPtr<T>
impl<T: Eq> Eq for TinyPtr<T>
impl<T> StructuralPartialEq for TinyPtr<T>
Auto Trait Implementations§
impl<T> Freeze for TinyPtr<T>
impl<T> RefUnwindSafe for TinyPtr<T>where
T: RefUnwindSafe,
impl<T> !Send for TinyPtr<T>
impl<T> !Sync for TinyPtr<T>
impl<T> Unpin for TinyPtr<T>
impl<T> UnwindSafe for TinyPtr<T>where
T: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more