Skip to content

Commit

Permalink
Add InstanceId::lookup_validity()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Sep 16, 2024
1 parent ccd67dc commit bc802b8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions godot-core/src/obj/instance_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ impl InstanceId {
self.to_u64() & (1u64 << 63) != 0
}

/// Dynamically checks if the instance behind the ID exists.
///
/// Rather slow, involves engine round-trip plus object DB lookup. If you need the object, use
/// [`Gd::from_instance_id()`][crate::obj::Gd::from_instance_id] instead.
pub fn lookup_validity(self) -> bool {
crate::gen::utilities::is_instance_id_valid(self.to_i64())
}

// Private: see rationale above
pub(crate) fn to_u64(self) -> u64 {
self.value.get()
Expand Down

0 comments on commit bc802b8

Please sign in to comment.