From 751d4f4fb90716424f536d96620f19a0e20d6bfc Mon Sep 17 00:00:00 2001 From: Quaternions Date: Sat, 21 Sep 2024 14:11:06 -0700 Subject: [PATCH] superclasses --- src/context.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/context.rs b/src/context.rs index 6f8c8f0..88989ae 100644 --- a/src/context.rs +++ b/src/context.rs @@ -2,12 +2,16 @@ use rbx_dom_weak::{types::Ref,WeakDom}; pub fn class_is_a(class:&str,superclass:&str)->bool{ class==superclass - ||rbx_reflection_database::get().classes.get(class) - .is_some_and(|descriptor| - descriptor.superclass.as_ref().is_some_and(|class_super| - class_is_a(class_super,superclass) - ) - ) + ||{ + let db=rbx_reflection_database::get(); + match (db.classes.get(class),db.classes.get(superclass)){ + (Some(class),Some(superclass))=>db.superclasses(class) + .unwrap() + .into_iter() + .any(|cls|core::ptr::addr_eq(cls,superclass)), + _=>false + } + } } #[repr(transparent)]