diff --git a/src/ffi_util.rs b/src/ffi_util.rs index c979f72..07c3bff 100644 --- a/src/ffi_util.rs +++ b/src/ffi_util.rs @@ -15,11 +15,10 @@ use libc::{self, c_char, c_void}; use std::ffi::CStr; -use std::str; pub fn error_message(ptr: *const c_char) -> String { let cstr = unsafe { CStr::from_ptr(ptr as *const _) }; - let s = str::from_utf8(cstr.to_bytes()).unwrap().to_owned(); + let s = String::from_utf8_lossy(cstr.to_bytes()).into(); unsafe { libc::free(ptr as *mut c_void); } diff --git a/src/rocksdb.rs b/src/rocksdb.rs index 248957c..4e5443f 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -911,10 +911,9 @@ fn errors_do_stuff() { // The DB will still be open when we try to destroy it and the lock should fail. match DB::destroy(&opts, path) { Err(s) => { - assert!(s == - Error::new("IO error: lock _rust_rocksdb_error/LOCK: No \ - locks available" - .to_owned())) + let message = s.to_string(); + assert!(message.find("IO error:").is_some()); + assert!(message.find("_rust_rocksdb_error/LOCK:").is_some()); } Ok(_) => panic!("should fail"), }