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§
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