turns out Result combinators are not marked with #[trace_caller], so it must be written without function nesting in order to work
This commit is contained in:
1 parent
3fa519563e
commit
af091c5bf8
1 file changed
+25
-25
@@ -263,19 +263,19 @@ impl<T> UseSharedState<T> {
|
|||||||
#[cfg_attr(debug_assertions, track_caller)]
|
#[cfg_attr(debug_assertions, track_caller)]
|
||||||
#[cfg_attr(debug_assertions, inline(never))]
|
#[cfg_attr(debug_assertions, inline(never))]
|
||||||
pub fn try_read(&self) -> UseSharedStateResult<Ref<'_, T>> {
|
pub fn try_read(&self) -> UseSharedStateResult<Ref<'_, T>> {
|
||||||
self.inner
|
match self.inner.try_borrow() {
|
||||||
.try_borrow()
|
Ok(value) => {
|
||||||
.map_err(|source| UseSharedStateError::AlreadyBorrowedMutably {
|
self.debug_track_borrow();
|
||||||
|
Ok(Ref::map(value, |inner| &inner.value))
|
||||||
|
}
|
||||||
|
Err(source) => Err(UseSharedStateError::AlreadyBorrowedMutably {
|
||||||
source,
|
source,
|
||||||
type_name: std::any::type_name::<Self>(),
|
type_name: std::any::type_name::<Self>(),
|
||||||
location: debug_location!(),
|
location: debug_location!(),
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
previous_borrow: *self.previous_borrow.borrow(),
|
previous_borrow: *self.previous_borrow.borrow(),
|
||||||
})
|
}),
|
||||||
.map(|value| {
|
}
|
||||||
self.debug_track_borrow();
|
|
||||||
Ref::map(value, |inner| &inner.value)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read the shared value
|
/// Read the shared value
|
||||||
@@ -295,20 +295,20 @@ impl<T> UseSharedState<T> {
|
|||||||
#[cfg_attr(debug_assertions, track_caller)]
|
#[cfg_attr(debug_assertions, track_caller)]
|
||||||
#[cfg_attr(debug_assertions, inline(never))]
|
#[cfg_attr(debug_assertions, inline(never))]
|
||||||
pub fn try_write(&self) -> UseSharedStateResult<RefMut<'_, T>> {
|
pub fn try_write(&self) -> UseSharedStateResult<RefMut<'_, T>> {
|
||||||
self.inner
|
match self.inner.try_borrow_mut() {
|
||||||
.try_borrow_mut()
|
Ok(mut value) => {
|
||||||
.map_err(|source| UseSharedStateError::AlreadyBorrowed {
|
self.debug_track_borrow_mut();
|
||||||
|
value.notify_consumers();
|
||||||
|
Ok(RefMut::map(value, |inner| &mut inner.value))
|
||||||
|
}
|
||||||
|
Err(source) => Err(UseSharedStateError::AlreadyBorrowed {
|
||||||
source,
|
source,
|
||||||
type_name: std::any::type_name::<Self>(),
|
type_name: std::any::type_name::<Self>(),
|
||||||
location: crate::debug_location!(),
|
location: crate::debug_location!(),
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
previous_borrow: *self.previous_borrow.borrow(),
|
previous_borrow: *self.previous_borrow.borrow(),
|
||||||
})
|
}),
|
||||||
.map(|mut value| {
|
}
|
||||||
value.notify_consumers();
|
|
||||||
self.debug_track_borrow_mut();
|
|
||||||
RefMut::map(value, |inner| &mut inner.value)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Calling "write" will force the component to re-render
|
/// Calling "write" will force the component to re-render
|
||||||
@@ -331,19 +331,19 @@ impl<T> UseSharedState<T> {
|
|||||||
#[cfg_attr(debug_assertions, track_caller)]
|
#[cfg_attr(debug_assertions, track_caller)]
|
||||||
#[cfg_attr(debug_assertions, inline(never))]
|
#[cfg_attr(debug_assertions, inline(never))]
|
||||||
pub fn try_write_silent(&self) -> UseSharedStateResult<RefMut<'_, T>> {
|
pub fn try_write_silent(&self) -> UseSharedStateResult<RefMut<'_, T>> {
|
||||||
self.inner
|
match self.inner.try_borrow_mut() {
|
||||||
.try_borrow_mut()
|
Ok(value) => {
|
||||||
.map_err(|source| UseSharedStateError::AlreadyBorrowed {
|
self.debug_track_borrow_mut();
|
||||||
|
Ok(RefMut::map(value, |inner| &mut inner.value))
|
||||||
|
}
|
||||||
|
Err(source) => Err(UseSharedStateError::AlreadyBorrowed {
|
||||||
source,
|
source,
|
||||||
type_name: std::any::type_name::<Self>(),
|
type_name: std::any::type_name::<Self>(),
|
||||||
location: crate::debug_location!(),
|
location: crate::debug_location!(),
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
previous_borrow: *self.previous_borrow.borrow(),
|
previous_borrow: *self.previous_borrow.borrow(),
|
||||||
})
|
}),
|
||||||
.map(|value| {
|
}
|
||||||
self.debug_track_borrow_mut();
|
|
||||||
RefMut::map(value, |inner| &mut inner.value)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Writes the value without forcing a re-render
|
/// Writes the value without forcing a re-render
|
||||||
|
|||||||
Reference in new issue
Block a user