rust/hg-direct-ffi/src/ancestors.rs
changeset 40863 443eb4bc41af
parent 40862 54a60968f0aa
child 40933 18513d6ef7d4
--- a/rust/hg-direct-ffi/src/ancestors.rs	Sun Dec 02 22:20:38 2018 +0900
+++ b/rust/hg-direct-ffi/src/ancestors.rs	Mon Oct 29 21:50:53 2018 +0900
@@ -139,7 +139,11 @@
 #[inline]
 fn raw_next<G: Graph>(raw: *mut AncestorsIterator<G>) -> c_long {
     let as_ref = unsafe { &mut *raw };
-    as_ref.next().unwrap_or(NULL_REVISION) as c_long
+    let rev = match as_ref.next() {
+        Some(Ok(rev)) => rev,
+        Some(Err(_)) | None => NULL_REVISION,
+    };
+    rev as c_long
 }
 
 #[no_mangle]
@@ -157,10 +161,10 @@
     target: c_long,
 ) -> c_int {
     let as_ref = unsafe { &mut *raw };
-    if as_ref.contains(target as Revision) {
-        return 1;
+    match as_ref.contains(target as Revision) {
+        Ok(r) => r as c_int,
+        Err(_) => -1,
     }
-    0
 }
 
 #[cfg(test)]