pub struct Shared<T> { /* private fields */ }Expand description
A synchronous shared container that works across platforms.
On wasm32 targets: uses Rc<RefCell<T>>
On other targets: uses Arc<RwLock<T>>
Implementations§
Sourcepub fn downgrade(&self) -> WeakShared<T>
pub fn downgrade(&self) -> WeakShared<T>
Creates a weak reference to this container.
Trait Implementations§
Source§fn read(&self) -> Result<SyncReadGuard<'_, T>, AccessError>
fn read(&self) -> Result<SyncReadGuard<'_, T>, AccessError>
Acquires a read lock on the container.
Source§fn write(&self) -> Result<SyncWriteGuard<'_, T>, AccessError>
fn write(&self) -> Result<SyncWriteGuard<'_, T>, AccessError>
Acquires a write lock on the container.
Source§fn get_cloned(&self) -> Result<T, AccessError>where
T: Clone,
fn get_cloned(&self) -> Result<T, AccessError>where
T: Clone,
Gets a clone of the contained value.
Auto Trait Implementations§
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