File tree Expand file tree Collapse file tree 1 file changed +8
-26
lines changed
Expand file tree Collapse file tree 1 file changed +8
-26
lines changed Original file line number Diff line number Diff line change @@ -37,37 +37,19 @@ impl ClassEntry {
3737 ///
3838 /// # Parameters
3939 ///
40- /// * `ce ` - The inherited class entry to check.
41- pub fn instance_of ( & self , ce : & ClassEntry ) -> bool {
42- if self == ce {
40+ /// * `other ` - The inherited class entry to check.
41+ pub fn instance_of ( & self , other : & ClassEntry ) -> bool {
42+ if self == other {
4343 return true ;
4444 }
4545
46- if ce. flags ( ) . contains ( ClassFlags :: Interface ) {
47- let interfaces = match self . interfaces ( ) {
48- Some ( interfaces) => interfaces,
49- None => return false ,
50- } ;
51-
52- for i in interfaces {
53- if ce == i {
54- return true ;
55- }
56- }
57- } else {
58- loop {
59- let parent = match self . parent ( ) {
60- Some ( parent) => parent,
61- None => return false ,
62- } ;
63-
64- if parent == ce {
65- return true ;
66- }
67- }
46+ if other. is_interface ( ) {
47+ return self
48+ . interfaces ( )
49+ . map_or ( false , |mut it| it. any ( |ce| ce == other) ) ;
6850 }
6951
70- false
52+ std :: iter :: successors ( self . parent ( ) , |p| p . parent ( ) ) . any ( |ce| ce == other )
7153 }
7254
7355 /// Returns an iterator of all the interfaces that the class implements.
You can’t perform that action at this time.
0 commit comments