Skip to content

Commit

Permalink
Change ReflectionDatabase::superclasses to use &ClassDescriptor i…
Browse files Browse the repository at this point in the history
…nstead of `&str` (#425)
  • Loading branch information
Dekkonot authored Jul 20, 2024
1 parent 944e747 commit 9683d6f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions rbx_reflection/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ impl<'a> ReflectionDatabase<'a> {
}
}

/// Returns a list of superclasses for the provided class name. This list
/// will start with the provided class and end with `Instance` if the class
/// exists.
pub fn superclasses(&self, class_name: &str) -> Option<Vec<&ClassDescriptor>> {
/// Returns a list of superclasses for the provided ClassDescriptor. This
/// list will start with the provided class and end with `Instance`.
pub fn superclasses(
&'a self,
descriptor: &'a ClassDescriptor<'a>,
) -> Option<Vec<&ClassDescriptor>> {
// As of the time of writing (14 March 2024), the class with the most
// superclasses has 6 of them.
let mut list = Vec::with_capacity(6);
let mut current_class = self.classes.get(class_name);
current_class?;
let mut current_class = Some(descriptor);

while let Some(class) = current_class {
list.push(class);
Expand Down

0 comments on commit 9683d6f

Please sign in to comment.