pub struct Ptr<'g, T> { /* private fields */ }
Expand description
Ptr
points to an instance.
Implementations§
source§impl<'g, T> Ptr<'g, T>
impl<'g, T> Ptr<'g, T>
sourcepub fn as_ref(&self) -> Option<&'g T>
pub fn as_ref(&self) -> Option<&'g T>
Tries to create a reference to the underlying instance.
§Examples
use sdd::{AtomicShared, Guard};
use std::sync::atomic::Ordering::Relaxed;
let atomic_shared: AtomicShared<usize> = AtomicShared::new(21);
let guard = Guard::new();
let ptr = atomic_shared.load(Relaxed, &guard);
assert_eq!(*ptr.as_ref().unwrap(), 21);
sourcepub fn as_ptr(&self) -> *const T
pub fn as_ptr(&self) -> *const T
Provides a raw pointer to the instance.
§Examples
use sdd::{Guard, Shared};
use std::sync::atomic::Ordering::Relaxed;
let shared: Shared<usize> = Shared::new(29);
let guard = Guard::new();
let ptr = shared.get_guarded_ptr(&guard);
drop(shared);
assert_eq!(unsafe { *ptr.as_ptr() }, 29);
sourcepub fn without_tag(self) -> Self
pub fn without_tag(self) -> Self
Tries to convert itself into a Shared
.
§Examples
use sdd::{Guard, Shared};
let shared: Shared<usize> = Shared::new(83);
let guard = Guard::new();
let ptr = shared.get_guarded_ptr(&guard);
let shared_restored = ptr.get_shared().unwrap();
assert_eq!(*shared_restored, 83);
drop(shared);
drop(shared_restored);
assert!(ptr.get_shared().is_none());
Trait Implementations§
source§impl<'g, T> PartialEq for Ptr<'g, T>
impl<'g, T> PartialEq for Ptr<'g, T>
impl<'g, T> Copy for Ptr<'g, T>
impl<'g, T> Eq for Ptr<'g, T>
impl<'g, T: UnwindSafe> UnwindSafe for Ptr<'g, T>
Auto Trait Implementations§
impl<'g, T> Freeze for Ptr<'g, T>
impl<'g, T> RefUnwindSafe for Ptr<'g, T>where
T: RefUnwindSafe,
impl<'g, T> !Send for Ptr<'g, T>
impl<'g, T> !Sync for Ptr<'g, T>
impl<'g, T> Unpin for Ptr<'g, T>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)