Skip to content

Commit

Permalink
fix: add missing track_callers for world.resource(). (#415)
Browse files Browse the repository at this point in the history
Submitting on behalf of @TekhnaeRaav.

This makes it easier to track panic messages originating from calls to
these functions.

---------

Co-authored-by: Tekhnae Raav <tekhnaeraav@katharostech.com>
  • Loading branch information
zicklag and TekhnaeRaav committed Jun 21, 2024
1 parent 5f20ac3 commit 16cb7f2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions framework_crates/bones_ecs/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ impl Resources {
}

/// Borrow a resource.
#[track_caller]
pub fn get<T: HasSchema>(&self) -> Option<Ref<T>> {
let b = self.untyped.get(T::schema()).borrow();
if b.is_some() {
Expand All @@ -254,6 +255,7 @@ impl Resources {
}

/// Borrow a resource.
#[track_caller]
pub fn get_mut<T: HasSchema>(&self) -> Option<RefMut<T>> {
let b = self.untyped.get(T::schema()).borrow_mut();
if b.is_some() {
Expand Down
2 changes: 2 additions & 0 deletions framework_crates/bones_lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ impl Game {
plugin.install(self);
self
}
#[track_caller]
/// Get the shared resource of a given type out of this [`Game`]s shared resources.
pub fn shared_resource<T: HasSchema>(&self) -> Option<Ref<T>> {
let res = self
Expand All @@ -226,6 +227,7 @@ impl Game {
}
}

#[track_caller]
/// Get the shared resource of a given type out of this [`Game`]s shared resources.
pub fn shared_resource_mut<T: HasSchema>(&self) -> Option<RefMut<T>> {
let res = self
Expand Down

0 comments on commit 16cb7f2

Please sign in to comment.