validation: refactor get_partial_path

This commit is contained in:
Quaternions 2025-03-27 12:22:27 -07:00 committed by Quaternions
parent b02b3d205e
commit af9f413b49

@ -321,22 +321,16 @@ fn recursive_collect_superclass(objects:&mut std::vec::Vec<rbx_dom_weak::types::
}
fn get_partial_path(dom:&rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance)->String{
struct ParentIter<'a>{
dom:&'a rbx_dom_weak::WeakDom,
instance:Option<&'a rbx_dom_weak::Instance>,
}
impl<'a> Iterator for ParentIter<'a>{
type Item=&'a rbx_dom_weak::Instance;
fn next(&mut self)->Option<Self::Item>{
let parent=self.instance.map(|i|i.parent()).and_then(|p|self.dom.get_by_ref(p));
core::mem::replace(&mut self.instance,parent)
}
}
let mut tragic:Vec<_>=ParentIter{dom,instance:Some(instance)}.map(|i|i.name.as_str()).collect();
tragic.pop();
tragic.reverse();
tragic.join(".")
let mut names:Vec<_>=core::iter::successors(
Some(instance),
|i|dom.get_by_ref(i.parent())
).map(
|i|i.name.as_str()
).collect();
// discard the name of the root object
names.pop();
names.reverse();
names.join(".")
}
fn get_script_refs(dom:&rbx_dom_weak::WeakDom)->Vec<rbx_dom_weak::types::Ref>{