Skip to content

Commit bc802b8

Browse files
committed
Add InstanceId::lookup_validity()
1 parent ccd67dc commit bc802b8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

godot-core/src/obj/instance_id.rs

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ impl InstanceId {
5858
self.to_u64() & (1u64 << 63) != 0
5959
}
6060

61+
/// Dynamically checks if the instance behind the ID exists.
62+
///
63+
/// Rather slow, involves engine round-trip plus object DB lookup. If you need the object, use
64+
/// [`Gd::from_instance_id()`][crate::obj::Gd::from_instance_id] instead.
65+
pub fn lookup_validity(self) -> bool {
66+
crate::gen::utilities::is_instance_id_valid(self.to_i64())
67+
}
68+
6169
// Private: see rationale above
6270
pub(crate) fn to_u64(self) -> u64 {
6371
self.value.get()

0 commit comments

Comments
 (0)