pub struct Dual<T> { /* private fields */ }Expand description
A dual-ownership (non-sync) reference cell
- uses a
Cell<bool>internally - implements
SendifTimplementsSend
you can access the value using the Deref impl
use duals::Dual;
// create a new `Dual`
let (left, right) = Dual::new(10);
println!("{:?} {:?}", *left, *right);
drop(left);
println!("{:?}", *right);
drop(right);Implementations§
Source§impl<T> Dual<T>
impl<T> Dual<T>
Sourcepub fn new(value: T) -> (Self, Self)
pub fn new(value: T) -> (Self, Self)
create a new Dual
use duals::Dual;
let (left, right) = Dual::new(10);Sourcepub fn other_exists(&self) -> bool
pub fn other_exists(&self) -> bool
check if the other Dual reference exists
use duals::Dual;
let (left, right) = Dual::new(10);
assert!(left.other_exists()); // true;
drop(right);
assert!(!left.other_exists()); // false;Trait Implementations§
impl<T> Send for Dual<T>where
T: Send,
Auto Trait Implementations§
impl<T> Freeze for Dual<T>
impl<T> !RefUnwindSafe for Dual<T>
impl<T> !Sync for Dual<T>
impl<T> Unpin for Dual<T>
impl<T> !UnwindSafe for Dual<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