rojo-rbx / rbx-dom

Roblox DOM and (de)serialization implementation in Rust
MIT License
105 stars 42 forks source link

Add method for getting UniqueId for referent #405

Closed Dekkonot closed 2 months ago

Dekkonot commented 3 months ago

Adds a method for getting the UniqueId for a given referent in a WeakDom.

Technically unnecessary but a convenience function is helpful and there's nothing stopping us from linking referents more directly to their UniqueId in the future, which this method would benefit from.

kennethloeffler commented 2 months ago

I think this is a reasonable addition. It provides an easy way to go from Ref to UniqueId, but it does make me consider that it's straight up impossible to go the other way around: UniqueId to Instance, assuming the consumer only has a UniqueId. Maybe we should have an additional method, something like

pub fn get_by_unique_id(&self, unique_id: UniqueId) -> Option<&Instance>