diff options
author | malfunc <malfunc@dane-bre.net> | 2016-10-27 15:30:52 +0200 |
---|---|---|
committer | malfunc <malfunc@dane-bre.net> | 2016-10-27 15:30:52 +0200 |
commit | f30ec3184bcf08d0f9462e745aaf1da23408c519 (patch) | |
tree | 1817266163b6806d261d1138f9c11148b3f511fd | |
parent | e72e466deca59d1ab26036b96731bb4114d915ba (diff) |
- changed output of fn num_args to option<u32>
- changed fn args to handle option<u32> instead of usize
-rwxr-xr-x | src/clang.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/clang.rs b/src/clang.rs index fa4eb01b..8e5a1a4f 100755 --- a/src/clang.rs +++ b/src/clang.rs @@ -393,7 +393,7 @@ impl Cursor { /// parameters. pub fn args(&self) -> Vec<Cursor> { unsafe { - let num = self.num_args() as usize; + let num = self.num_args().expect("expected value, got none") as u32; let mut args = vec![]; for i in 0..num { args.push(Cursor { x: clang_Cursor_getArgument(self.x, i as c_uint) }); @@ -415,9 +415,14 @@ impl Cursor { /// /// Returns -1 if the cursor's referent is not a function/method call or /// declaration. - pub fn num_args(&self) -> i32 { + pub fn num_args(&self) -> Option<u32> { unsafe { - clang_Cursor_getNumArguments(self.x) + let w = clang_Cursor_getNumArguments(self.x); + if w == -1 { + None + } else { + Some(w as u32) + } } } |