Fix generational box in release mode

This commit is contained in:
Jonathan Kelley committed 2024-01-21 12:46:19 -08:00
1 parent 06d9b575b7
commit 028f499bf6
10 files changed
+182 -34

No files matched your search

+16 -8
View File
@@ -54,10 +54,14 @@ impl<T: 'static> Storage<T> for UnsyncStorage {
#[cfg(any(debug_assertions, feature = "debug_ownership"))]
at: crate::GenerationalRefBorrowInfo,
) -> Result<Self::Ref, crate::error::BorrowError> {
let borrow = self
.0
.try_borrow()
.map_err(|_| at.borrowed_from.borrow_error())?;
let borrow = self.0.try_borrow();
#[cfg(any(debug_assertions, feature = "debug_ownership"))]
let borrow = borrow.map_err(|_| at.borrowed_from.borrow_error())?;
#[cfg(not(any(debug_assertions, feature = "debug_ownership")))]
let borrow = borrow.unwrap();
Ref::filter_map(borrow, |any| any.as_ref()?.downcast_ref())
.map_err(|_| {
crate::error::BorrowError::Dropped(crate::error::ValueDroppedError {
@@ -81,10 +85,14 @@ impl<T: 'static> Storage<T> for UnsyncStorage {
#[cfg(any(debug_assertions, feature = "debug_ownership"))]
at: crate::GenerationalRefMutBorrowInfo,
) -> Result<Self::Mut, crate::error::BorrowMutError> {
let borrow = self
.0
.try_borrow_mut()
.map_err(|_| at.borrowed_from.borrow_mut_error())?;
let borrow = self.0.try_borrow_mut();
#[cfg(any(debug_assertions, feature = "debug_ownership"))]
let borrow = borrow.map_err(|_| at.borrowed_from.borrow_mut_error())?;
#[cfg(not(any(debug_assertions, feature = "debug_ownership")))]
let borrow = borrow.unwrap();
RefMut::filter_map(borrow, |any| any.as_mut()?.downcast_mut())
.map_err(|_| {
crate::error::BorrowMutError::Dropped(crate::error::ValueDroppedError {