From cc3772680f7b29bee9ba0d5424fdf0bf5ece8bed Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Fri, 31 Mar 2023 10:51:40 +0200 Subject: [PATCH] Fix using instances as keys in tables --- CHANGELOG.md | 6 ++++++ packages/lib-roblox/src/instance/mod.rs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cad4c67..f404bf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fixed using instances as keys in tables + ## `0.6.5` - March 27th, 2023 ### Changed diff --git a/packages/lib-roblox/src/instance/mod.rs b/packages/lib-roblox/src/instance/mod.rs index ab96b99..ab62bb5 100644 --- a/packages/lib-roblox/src/instance/mod.rs +++ b/packages/lib-roblox/src/instance/mod.rs @@ -1,6 +1,7 @@ use std::{ collections::{BTreeMap, HashMap, VecDeque}, fmt, + hash::{Hash, Hasher}, sync::RwLock, }; @@ -1136,6 +1137,12 @@ impl LuaUserData for Instance { } } +impl Hash for Instance { + fn hash(&self, state: &mut H) { + self.dom_ref.hash(state) + } +} + impl fmt::Display for Instance { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(