pub struct AtomicLendCell<T> { /* private fields */ }Expand description
A container that allows thread-safe lending of its contained value
AtomicLendCell<T> owns a value of type T and maintains an atomic reference count
to track outstanding borrows. It ensures that the value isn’t dropped while
borrows exist, panicking if this invariant would be violated.
Implementations§
Source§impl<T> AtomicLendCell<T>
impl<T> AtomicLendCell<T>
Source§impl<T> AtomicLendCell<T>
impl<T> AtomicLendCell<T>
Sourcepub fn new(data: T) -> Self
pub fn new(data: T) -> Self
Creates a new AtomicLendCell containing the given value
§Examples
use atomic_lend_cell::AtomicLendCell;
let cell = AtomicLendCell::new(42);Sourcepub fn borrow(&self) -> AtomicBorrowCell<T>
pub fn borrow(&self) -> AtomicBorrowCell<T>
Creates a new AtomicBorrowCell for the contained value
This increments the internal reference count and returns a borrow that can be sent to other threads. The borrow will automatically decrement the reference count when dropped.
§Examples
use atomic_lend_cell::AtomicLendCell;
let cell = AtomicLendCell::new(42);
let borrow = cell.borrow();
assert_eq!(*borrow, 42);Source§impl<'a, T> AtomicLendCell<&'a T>
impl<'a, T> AtomicLendCell<&'a T>
Sourcepub fn borrow_deref(&'a self) -> AtomicBorrowCell<T>
pub fn borrow_deref(&'a self) -> AtomicBorrowCell<T>
Creates a new AtomicBorrowCell that borrows the referenced value directly
This is useful when the AtomicLendCell contains a reference, and you want to
borrow the underlying value rather than the reference itself.