pub struct AnyObj { /* private fields */ }
Expand description
A type-erased wrapper for a reference, whether it is mutable or not.
Implementations§
Source§impl AnyObj
impl AnyObj
Sourcepub fn borrow_ref<T>(&self) -> Result<BorrowRef<'_, T>, AnyObjError>where
T: Any,
pub fn borrow_ref<T>(&self) -> Result<BorrowRef<'_, T>, AnyObjError>where
T: Any,
Get a reference to the interior value while checking for shared access.
This prevents other exclusive accesses from being performed while the guard returned from this function is live.
Sourcepub fn try_borrow_ref<T>(&self) -> Result<Option<BorrowRef<'_, T>>, AccessError>where
T: Any,
pub fn try_borrow_ref<T>(&self) -> Result<Option<BorrowRef<'_, T>>, AccessError>where
T: Any,
Try to borrow a reference to the interior value while checking for shared access.
Returns None
if the interior type is not T
.
This prevents other exclusive accesses from being performed while the guard returned from this function is alive.
Sourcepub fn try_borrow_mut<T>(&self) -> Result<Option<BorrowMut<'_, T>>, AccessError>where
T: Any,
pub fn try_borrow_mut<T>(&self) -> Result<Option<BorrowMut<'_, T>>, AccessError>where
T: Any,
Try to borrow a reference to the interior value while checking for exclusive access.
Returns None
if the interior type is not T
.
This prevents other exclusive accesses from being performed while the guard returned from this function is alive.
Sourcepub fn borrow_mut<T>(&self) -> Result<BorrowMut<'_, T>, AnyObjError>where
T: Any,
pub fn borrow_mut<T>(&self) -> Result<BorrowMut<'_, T>, AnyObjError>where
T: Any,
Returns some mutable reference to the boxed value if it is of type T
.