[−][src]Struct ping_pong_cell::PingPongCell
An Atomic Cell game for up to two players.
Implementations
impl<T> PingPongCell<T>
[src]
pub fn new(value: Option<T>) -> Self
[src]
Create a new PingPongCell
pub fn take(&self) -> Option<T>
[src]
If there is a value currently inside, take it.
pub fn put(&self, value: T)
[src]
Replace the value inside unconditionally.
pub fn put_if_empty(&self, value: T) -> Result<(), T>
[src]
Puts a value inside only if there is not one currently.
pub fn transact<F, R>(&self, fun: F) -> R where
F: FnOnce(&mut Option<T>) -> R,
[src]
F: FnOnce(&mut Option<T>) -> R,
Runs a closure with a mutable reference to the state
impl<T: Clone> PingPongCell<T>
[src]
pub fn put_empty_clone(&self, value: T) -> Result<(), (T, T)>
[src]
put_empty()
, but clones the current contents on failure
pub fn clone_inner(&self) -> Option<T>
[src]
Clones the contents, if any.
impl<T: Eq> PingPongCell<T>
[src]
pub fn compare_and_swap(&self, expected: &T, new: T) -> Result<(), T>
[src]
A single CAS operation
impl<T: Clone + Eq> PingPongCell<T>
[src]
pub fn compare_swap_clone(
&self,
expected: &T,
new: T
) -> Result<(), (T, Option<T>)>
[src]
&self,
expected: &T,
new: T
) -> Result<(), (T, Option<T>)>
A single CAS operation, cloning the current value on failure
Trait Implementations
impl<T: Debug> Debug for PingPongCell<T>
[src]
impl<T: Send> Send for PingPongCell<T>
[src]
impl<T: Sync> Sync for PingPongCell<T>
[src]
Auto Trait Implementations
impl<T> Unpin for PingPongCell<T> where
T: Unpin,
T: Unpin,
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,
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, 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.
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>,