File tree 2 files changed +7
-4
lines changed
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -678,9 +678,12 @@ impl Type {
678
678
679
679
/// Given that this type is an array or vector type, return its number of
680
680
/// elements.
681
- pub fn num_elements ( & self ) -> usize {
682
- unsafe {
683
- clang_getNumElements ( self . x ) as usize
681
+ pub fn num_elements ( & self ) -> Option < usize > {
682
+ let num_elements_returned = unsafe { clang_getNumElements ( self . x ) } ;
683
+ if num_elements_returned != -1 {
684
+ Some ( num_elements_returned as usize )
685
+ } else {
686
+ None
684
687
}
685
688
}
686
689
Original file line number Diff line number Diff line change @@ -681,7 +681,7 @@ impl Type {
681
681
CXType_ConstantArray => {
682
682
let inner = Item :: from_ty ( & ty. elem_type ( ) , location, parent_id, ctx)
683
683
. expect ( "Not able to resolve array element?" ) ;
684
- TypeKind :: Array ( inner, ty. num_elements ( ) )
684
+ TypeKind :: Array ( inner, ty. num_elements ( ) . unwrap ( ) )
685
685
}
686
686
// A complex number is always a real and an imaginary part, so
687
687
// represent that as a two-item array.
You can’t perform that action at this time.
0 commit comments