pub trait FragileMutContainer<T: ?Sized>: FragileTryMutContainer<T> + FragileContainer<T> {
// Required method
fn get_mut(&mut self) -> Self::RefMut<'_>;
}Expand description
An abstraction over some container which owns a T and can infallibly provide mutable or
immutable references to it, or attempt to be consumed to return the inner T
(if T is Sized).
§Fragility: Potential Panics or Deadlocks
This container should be assumed to be fragile, unless it is known to implement
MutContainer<T>.
§None values
Note that into_inner is still permitted to return None, even though get_ref and
get_mut do not fail, and most implementors should make try_get_ref and try_get_mut
infallible as well. A container should clearly document when into_inner returns None.
Required Methods§
Sourcefn get_mut(&mut self) -> Self::RefMut<'_>
fn get_mut(&mut self) -> Self::RefMut<'_>
Mutably borrow the inner T.
§Fragility: Potential Panics or Deadlocks
Unless this FragileMutContainer is also a MutContainer, implementations are
permitted to panic or deadlock if this method is called from a thread which already has a
reference to the inner T of this container.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<T: ?Sized> FragileMutContainer<T> for Arc<Mutex<T>>
Available on crate features std only.
impl<T: ?Sized> FragileMutContainer<T> for Arc<Mutex<T>>
std only.Source§fn get_mut(&mut self) -> Self::RefMut<'_>
fn get_mut(&mut self) -> Self::RefMut<'_>
Get mutable access to the inner T.
Uses Mutex::lock, so this container is
fragile.
§Panics and Deadlocks
Panics if a poison error is encountered, which can only occur if another thread has already panicked.
May also panic or deadlock if the contract of a fragile container is broken.
Source§impl<T: ?Sized> FragileMutContainer<T> for Arc<RwLock<T>>
Available on crate features std only.
impl<T: ?Sized> FragileMutContainer<T> for Arc<RwLock<T>>
std only.Source§fn get_mut(&mut self) -> Self::RefMut<'_>
fn get_mut(&mut self) -> Self::RefMut<'_>
Get mutable access to the inner T.
Uses RwLock::write, so this container is
fragile.
§Panics and Deadlocks
Panics if a poison error is encountered, which can only occur if another thread has already panicked.
May also panic or deadlock if the contract of a fragile container is broken.
Source§impl<T: ?Sized> FragileMutContainer<T> for Box<T>
Available on crate features alloc only.
impl<T: ?Sized> FragileMutContainer<T> for Box<T>
alloc only.Source§impl<T: ?Sized> FragileMutContainer<T> for Rc<RefCell<T>>
Available on crate features alloc only.
impl<T: ?Sized> FragileMutContainer<T> for Rc<RefCell<T>>
alloc only.