File tree 2 files changed +9
-4
lines changed 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -796,9 +796,13 @@ impl Comment {
796
796
}
797
797
798
798
/// Get this comment's `idx`th child comment
799
- pub fn get_child ( & self , idx : c_uint ) -> Comment {
800
- unsafe {
801
- Comment { x : clang_Comment_getChild ( self . x , idx) }
799
+ pub fn get_child ( & self , idx : c_uint ) -> Option < Comment > {
800
+ if idx >= self . num_children ( ) {
801
+ None
802
+ } else {
803
+ unsafe {
804
+ Some ( Comment { x : clang_Comment_getChild ( self . x , idx) } )
805
+ }
802
806
}
803
807
}
804
808
Original file line number Diff line number Diff line change @@ -153,7 +153,8 @@ impl Annotations {
153
153
}
154
154
155
155
for i in 0 ..comment. num_children ( ) {
156
- self . parse ( & comment. get_child ( i) , matched) ;
156
+ let child = & comment. get_child ( i) . expect ( "index higher than number of children" ) ;
157
+ self . parse ( child, matched) ;
157
158
}
158
159
}
159
160
}
You can’t perform that action at this time.
0 commit comments