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 {
37
37
///
38
38
/// # Parameters
39
39
///
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 {
43
43
return true ;
44
44
}
45
45
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) ) ;
68
50
}
69
51
70
- false
52
+ std :: iter :: successors ( self . parent ( ) , |p| p . parent ( ) ) . any ( |ce| ce == other )
71
53
}
72
54
73
55
/// Returns an iterator of all the interfaces that the class implements.
You can’t perform that action at this time.
0 commit comments