Skip to content

Commit

Permalink
Merge pull request #1279 from RealKC/track-caller
Browse files Browse the repository at this point in the history
glib: Mark panicky `BoxedAnyObject` methods as `track_caller`
  • Loading branch information
sdroege authored Jan 15, 2024
2 parents d08bf24 + b3e4322 commit e377292
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions glib/src/boxed_any_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl BoxedAnyObject {
// rustdoc-stripper-ignore-next
/// Replaces the wrapped value with a new one, returning the old value, without deinitializing either one.
/// The returned value is inside a `Box` and must be manually downcasted if needed.
#[track_caller]
pub fn replace<T: 'static>(&self, t: T) -> Box<dyn Any> {
self.imp().value.replace(Box::new(t) as Box<dyn Any>)
}
Expand Down Expand Up @@ -158,6 +159,7 @@ impl BoxedAnyObject {
///
/// For a non-panicking variant, use
/// [`try_borrow`](#method.try_borrow).
#[track_caller]
pub fn borrow<T: 'static>(&self) -> Ref<'_, T> {
Ref::map(self.imp().value.borrow(), |value| {
value
Expand All @@ -180,6 +182,7 @@ impl BoxedAnyObject {
///
/// For a non-panicking variant, use
/// [`try_borrow_mut`](#method.try_borrow_mut).
#[track_caller]
pub fn borrow_mut<T: 'static>(&self) -> RefMut<'_, T> {
RefMut::map(self.imp().value.borrow_mut(), |value| {
value
Expand Down

0 comments on commit e377292

Please sign in to comment.