From 3235e86b6b764f1ba2e8378b5df1bd15b096d858 Mon Sep 17 00:00:00 2001 From: Andrey Davydov Date: Fri, 2 Jan 2015 21:57:18 +0300 Subject: [PATCH 1/5] redundant lifetime parameter removed --- src/rocksdb.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rocksdb.rs b/src/rocksdb.rs index 53893ae..973bab4 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -577,9 +577,9 @@ pub struct MergeOperands<'a> { } impl <'a> MergeOperands<'a> { - fn new<'a>(operands_list: *const *const c_char, - operands_list_len: *const size_t, - num_operands: c_int) -> MergeOperands<'a> { + fn new(operands_list: *const *const c_char, + operands_list_len: *const size_t, + num_operands: c_int) -> MergeOperands<'a> { assert!(num_operands >= 0); MergeOperands { operands_list: operands_list, From 36022a68658ebab7f37cd94a332b477ce3519d92 Mon Sep 17 00:00:00 2001 From: Andrey Davydov Date: Fri, 2 Jan 2015 21:57:50 +0300 Subject: [PATCH 2/5] proc() replaced to unboxed closure --- src/rocksdb.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rocksdb.rs b/src/rocksdb.rs index 973bab4..8875084 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -23,6 +23,7 @@ use std::string::raw::from_buf_len; use std::ptr; use std::mem; use std::slice; +use std::ptr::Unique; use rocksdb_ffi; @@ -463,10 +464,11 @@ pub struct RocksDBVector { impl RocksDBVector { pub fn from_c(val: *mut u8, val_len: size_t) -> RocksDBVector { unsafe { + let val = Unique(val); RocksDBVector { inner: - CVec::new_with_dtor(val, val_len as uint, - proc(){ libc::free(val as *mut c_void); }) + CVec::new_with_dtor(val.0, val_len as uint, + move |:| libc::free(val.0 as *mut libc::c_void)) } } } From 0351d734334746ce0f5c9a0e96bfb659fc9d63e9 Mon Sep 17 00:00:00 2001 From: Andrey Davydov Date: Fri, 2 Jan 2015 22:44:47 +0300 Subject: [PATCH 3/5] unused import removed --- src/rocksdb.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/rocksdb.rs b/src/rocksdb.rs index 8875084..646ef3a 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -22,7 +22,6 @@ use std::str::from_utf8; use std::string::raw::from_buf_len; use std::ptr; use std::mem; -use std::slice; use std::ptr::Unique; use rocksdb_ffi; From 75293105919fe35a5acdd30ee729396784ad8f2a Mon Sep 17 00:00:00 2001 From: Andrey Davydov Date: Fri, 2 Jan 2015 22:45:17 +0300 Subject: [PATCH 4/5] missing Copy implementations added --- src/ffi.rs | 9 +++++++++ src/rocksdb.rs | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/ffi.rs b/src/ffi.rs index d9177ff..56e597b 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -33,6 +33,15 @@ pub struct RocksDBCache(pub *const c_void); #[repr(C)] pub struct RocksDBFilterPolicy(pub *const c_void); +impl Copy for RocksDBOptions {} +impl Copy for RocksDBInstance {} +impl Copy for RocksDBWriteOptions {} +impl Copy for RocksDBReadOptions {} +impl Copy for RocksDBMergeOperator {} +impl Copy for RocksDBBlockBasedTableOptions {} +impl Copy for RocksDBCache {} +impl Copy for RocksDBFilterPolicy {} + pub fn new_bloom_filter(bits: c_int) -> RocksDBFilterPolicy { unsafe { rocksdb_filterpolicy_create_bloom(bits) diff --git a/src/rocksdb.rs b/src/rocksdb.rs index 646ef3a..67e5d04 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -31,6 +31,8 @@ pub struct RocksDBOptions { block_options: rocksdb_ffi::RocksDBBlockBasedTableOptions, } +impl Copy for RocksDBOptions {} + impl RocksDBOptions { pub fn new() -> RocksDBOptions { unsafe { From 064370072cb100ec31541faf29160f5a7a067634 Mon Sep 17 00:00:00 2001 From: Andrey Davydov Date: Fri, 2 Jan 2015 22:46:43 +0300 Subject: [PATCH 5/5] missing 'Result -> Option' conversion added --- src/rocksdb.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rocksdb.rs b/src/rocksdb.rs index 67e5d04..783f770 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -478,8 +478,8 @@ impl RocksDBVector { self.inner.as_slice() } - pub fn to_utf8<'a>(&'a self) -> Option<&'a str> { - from_utf8(self.inner.as_slice()) + pub fn to_utf8(&self) -> Option<&str> { + from_utf8(self.inner.as_slice()).ok() } }