pub struct RefCounter { /* private fields */ }
Expand description
RefCounter
is a data-structure designed specifically for
internal use in [UniquePointer
] allowing reference counts to be
shared across clones of [UniquePointer
].
RefCounter
uses relatively obscure rust techniques under
the hood to allow writing in non-mut references in strategic
occasions such as incrementing its reference count within its
Clone
implementation.
Implementations§
Source§impl RefCounter
impl RefCounter
Sourcepub fn null() -> RefCounter
pub fn null() -> RefCounter
new
creates a new RefCounter
with its internal state
equivalent to zero.
Sourcepub fn new() -> RefCounter
pub fn new() -> RefCounter
new
creates a new RefCounter
with the value 1
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
reset
resets a RefCounter
to one which is the equivalent
state of a RefCounter::new
.
Sourcepub fn drain(&mut self)
pub fn drain(&mut self)
drain
deallocates the memory used by a RefCounter
resetting its internals so as to behave as though it has been
written 0
.
pub fn read(&self) -> usize
Sourcepub fn write(&self, data: usize)
pub fn write(&self, data: usize)
write
writes a usize
into a RefCounter
as opposed to
incrementing or decrementing it.
Sourcepub fn inner_ref<'c>(&self) -> &'c usize
pub fn inner_ref<'c>(&self) -> &'c usize
inner_ref
returns a reference to the internal data of a
RefCounter
. Writing to the memory area if not already
allocated.
Sourcepub fn inner_mut<'c>(&self) -> &'c mut usize
pub fn inner_mut<'c>(&self) -> &'c mut usize
inner_mut
returns a mutable reference to the internal data
of a RefCounter
. Writing to the memory area if not already
allocated.
Trait Implementations§
Source§impl AddAssign<usize> for RefCounter
impl AddAssign<usize> for RefCounter
Source§fn add_assign(&mut self, other: usize)
fn add_assign(&mut self, other: usize)
+=
operation. Read moreSource§impl AsMut<usize> for RefCounter
impl AsMut<usize> for RefCounter
Source§impl AsRef<usize> for RefCounter
impl AsRef<usize> for RefCounter
Source§impl Clone for RefCounter
impl Clone for RefCounter
Source§fn clone(&self) -> RefCounter
fn clone(&self) -> RefCounter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for RefCounter
impl Debug for RefCounter
Source§impl Deref for RefCounter
impl Deref for RefCounter
Source§impl DerefMut for RefCounter
impl DerefMut for RefCounter
Source§impl Display for RefCounter
impl Display for RefCounter
Source§impl Drop for RefCounter
impl Drop for RefCounter
Source§impl From<usize> for RefCounter
impl From<usize> for RefCounter
Source§fn from(refs: usize) -> RefCounter
fn from(refs: usize) -> RefCounter
Source§impl Ord for RefCounter
impl Ord for RefCounter
Source§fn cmp(&self, other: &RefCounter) -> Ordering
fn cmp(&self, other: &RefCounter) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq<usize> for RefCounter
impl PartialEq<usize> for RefCounter
Source§impl PartialEq for RefCounter
impl PartialEq for RefCounter
Source§impl PartialOrd<usize> for RefCounter
impl PartialOrd<usize> for RefCounter
Source§impl PartialOrd for RefCounter
impl PartialOrd for RefCounter
Source§impl SubAssign<usize> for RefCounter
impl SubAssign<usize> for RefCounter
Source§fn sub_assign(&mut self, other: usize)
fn sub_assign(&mut self, other: usize)
-=
operation. Read more