diff --git a/godot-core/src/obj/gd.rs b/godot-core/src/obj/gd.rs index 6d10f5a18..0e63d946c 100644 --- a/godot-core/src/obj/gd.rs +++ b/godot-core/src/obj/gd.rs @@ -654,6 +654,16 @@ impl Debug for Gd { } } +impl std::hash::Hash for Gd { + /// ⚠️ Hashes this object based on its instance ID. + /// + /// # Panics + /// When `self` is dead. + fn hash(&self, state: &mut H) { + self.instance_id().hash(state); + } +} + // Gd unwinding across panics does not invalidate any invariants; // its mutability is anyway present, in the Godot engine. impl std::panic::UnwindSafe for Gd {}