File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -457,8 +457,26 @@ impl Cursor {
457
457
/// Given that this cursor's referent is a template specialization, and that
458
458
/// the `i`th template argument is an integral, get the `i`th template
459
459
/// argument value.
460
- pub fn template_arg_value ( & self , i : c_int ) -> c_longlong {
461
- unsafe { clang_Cursor_getTemplateArgumentValue ( self . x , i as c_uint ) }
460
+ pub fn template_arg_value ( & self , i : c_int ) -> Option < c_longlong > {
461
+ let within_bounds = match self . num_template_args ( ) {
462
+ Some ( num_args) => {
463
+ if i > 0 && i < ( num_args as i32 ) {
464
+ true
465
+ }
466
+ else {
467
+ false
468
+ }
469
+ } ,
470
+ None => false
471
+ } ;
472
+ match within_bounds {
473
+ true => {
474
+ unsafe {
475
+ Some ( clang_Cursor_getTemplateArgumentValue ( self . x , i as c_uint ) )
476
+ }
477
+ } ,
478
+ false => None
479
+ }
462
480
}
463
481
}
464
482
You can’t perform that action at this time.
0 commit comments