Struct corundum::ptr::LogNonNull
source · [−]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 = Allocator;
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
sourceimpl<T: PSafe, A: MemPool> LogNonNull<T, A>
impl<T: PSafe, A: MemPool> LogNonNull<T, A>
Trait Implementations
sourceimpl<T: PSafe + ?Sized, A: MemPool> PartialEq<LogNonNull<T, A>> for LogNonNull<T, A>
impl<T: PSafe + ?Sized, A: MemPool> PartialEq<LogNonNull<T, A>> for LogNonNull<T, A>
impl<T: PSafe + ?Sized, A: MemPool> Copy for LogNonNull<T, A>
impl<T: Eq + PSafe + ?Sized, A: Eq + MemPool> Eq for LogNonNull<T, A>
impl<T: ?Sized, A: MemPool> !Send for LogNonNull<T, A>
impl<T: PSafe + ?Sized, A: MemPool> StructuralEq for LogNonNull<T, A>
impl<T: ?Sized, A: MemPool> !Sync for LogNonNull<T, A>
impl<T: ?Sized, A: MemPool> !TxOutSafe for LogNonNull<T, A>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more