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 @@ -793,9 +793,13 @@ impl Comment {
793
793
}
794
794
795
795
/// Get this comment's `idx`th child comment
796
- pub fn get_child ( & self , idx : c_uint ) -> Comment {
797
- unsafe {
798
- Comment { x : clang_Comment_getChild ( self . x , idx) }
796
+ pub fn get_child ( & self , idx : c_uint ) -> Option < Comment > {
797
+ if idx >= self . num_children ( ) {
798
+ None
799
+ } else {
800
+ unsafe {
801
+ Some ( Comment { x : clang_Comment_getChild ( self . x , idx) } )
802
+ }
799
803
}
800
804
}
801
805
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