[−][src]Struct crndm::ptr::LogNonNull
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. LogRefCell
::
as_non_null_mut()
is an alternative to LogRefCell
::
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 crndm::default::*; use crndm::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
impl<T: PSafe, A: MemPool> LogNonNull<T, A>
[src]
pub const unsafe fn new_unchecked(
ptr: *mut T,
logged: *mut u8,
j: &Journal<A>
) -> Self
[src]
ptr: *mut T,
logged: *mut u8,
j: &Journal<A>
) -> Self
pub unsafe fn new(ptr: *mut T, logged: *mut u8, j: &Journal<A>) -> Option<Self>
[src]
Creates a Some(LogNonNull)
if ptr
is not null; otherwise None
.
Trait Implementations
impl<T: PSafe + ?Sized, A: MemPool> Clone for LogNonNull<T, A>
[src]
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: PSafe + ?Sized, A: MemPool> Copy for LogNonNull<T, A>
[src]
impl<T: Debug + PSafe + ?Sized, A: MemPool> Debug for LogNonNull<T, A>
[src]
impl<T: PSafe + ?Sized, A: MemPool> Deref for LogNonNull<T, A>
[src]
impl<T: PSafe + ?Sized, A: MemPool> DerefMut for LogNonNull<T, A>
[src]
impl<T: Display + PSafe + ?Sized, A: MemPool> Display for LogNonNull<T, A>
[src]
impl<T: ?Sized, A: MemPool> !Send for LogNonNull<T, A>
[src]
impl<T: ?Sized, A: MemPool> !Sync for LogNonNull<T, A>
[src]
impl<T: ?Sized, A: MemPool> !TxOutSafe for LogNonNull<T, A>
[src]
Auto Trait Implementations
impl<T, A> !LooseTxInUnsafe for LogNonNull<T, A>
[src]
impl<T, A> !PSafe for LogNonNull<T, A>
[src]
impl<T, A> !RefUnwindSafe for LogNonNull<T, A>
[src]
impl<T, A> !TxInSafe for LogNonNull<T, A>
[src]
impl<T: ?Sized, A> Unpin for LogNonNull<T, A>
[src]
impl<T, A> !UnwindSafe for LogNonNull<T, A>
[src]
impl<T, A> !VSafe for LogNonNull<T, A>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, A> ToString<A> for T where
A: MemPool,
T: Display + ?Sized,
[src]
A: MemPool,
T: Display + ?Sized,
pub default fn to_pstring(&Self, &Journal<A>) -> String<A>
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,