Struct corundum::ptr::LogNonNull [−][src]
Expand description
An unsafe pointer with dereferencing and logging capability
This type is !PSafe
and its constructor functions are unsafe
. This is
because of LogNonNull
treating like a raw pointer. LogNonNull
objects are
useful for obtaining performance. PRefCell
::
as_non_null_mut()
is an alternative to PRefCell
::
borrow_mut()
which provides unsafe
mutable access to the underlying data.
PNonNullMut
is an alias name in the pool module for LogNonNullMut
.
Safety
- As in raw pointers,
LogNonNull
isCopy
and is not bounded to a specific lifetime. - It does not follow the borrow mechanism and thus multiple mutable access is possible.
Examples
use corundum::default::*; use corundum::ptr::LogNonNull; type P = BuddyAlloc; fn multiply(mut obj: LogNonNull<i32,P>, m: i32) { // Takes a log if required and then provides mut ref to the object *obj *= m; } let root = P::open::<PRefCell<i32>>("foo.pool", O_CF).unwrap(); P::transaction(|j| { let mut borrow = root.borrow_mut(j); *borrow = 5; multiply( unsafe { root.as_non_null_mut(j) }, 10 ); }).unwrap(); assert_eq!(*root.borrow(), 50);
Implementations
Trait Implementations
Auto Trait Implementations
impl<T, A> LooseTxInUnsafe for LogNonNull<T, A>
impl<T, A> !PSafe for LogNonNull<T, A>
impl<T: ?Sized, A> PSend for LogNonNull<T, A> where
A: PSend,
T: PSend,
impl<T, A> !RefUnwindSafe for LogNonNull<T, A>
impl<T, A> !TxInSafe for LogNonNull<T, A>
impl<T: ?Sized, A> Unpin for LogNonNull<T, A>
impl<T, A> !UnwindSafe for LogNonNull<T, A>
impl<T: ?Sized, A> VSafe for LogNonNull<T, A>
Blanket Implementations
Mutably borrows from an owned value. Read more