Last active
April 11, 2018 22:46
-
-
Save Enet4/209bce64ed8174598a1c584c92e95554 to your computer and use it in GitHub Desktop.
error.rs at faiss-rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug, Clone, PartialEq)] | |
pub struct NativeError { | |
code: c_int, | |
msg: String, | |
} | |
impl NativeError { | |
pub fn from_last_error(code: c_int) -> Self { | |
unsafe { | |
let e: *const _ = faiss_get_last_error(); | |
assert!(!e.is_null()); | |
let cstr = CStr::from_ptr(e); | |
let msg: String = cstr.to_string_lossy().into_owned(); | |
NativeError { code, msg } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment