changed try_ffi to take trailing comma and updated rustfmt accordingly

master
Rick Richardson 7 years ago
parent 3377a30391
commit 8a64585520
  1. 1
      rustfmt.toml
  2. 2
      src/backup.rs
  3. 11
      src/db.rs
  4. 2
      src/ffi_util.rs

@ -1,3 +1,4 @@
reorder_imports = true reorder_imports = true
max_width = 100 max_width = 100
ideal_width = 100 ideal_width = 100
trailing_comma = always

@ -52,7 +52,7 @@ impl BackupEngine {
}; };
let be: *mut ffi::rocksdb_backup_engine_t; let be: *mut ffi::rocksdb_backup_engine_t;
unsafe { be = ffi_try!(ffi::rocksdb_backup_engine_open(opts.inner, cpath.as_ptr())) } unsafe { be = ffi_try!(ffi::rocksdb_backup_engine_open(opts.inner, cpath.as_ptr(),)) }
if be.is_null() { if be.is_null() {
return Err(Error::new("Could not initialize backup engine.".to_owned())); return Err(Error::new("Could not initialize backup engine.".to_owned()));

@ -618,7 +618,7 @@ impl DB {
if cfs.len() == 0 { if cfs.len() == 0 {
unsafe { unsafe {
db = ffi_try!(ffi::rocksdb_open(opts.inner, cpath.as_ptr() as *const _)); db = ffi_try!(ffi::rocksdb_open(opts.inner, cpath.as_ptr() as *const _,));
} }
} else { } else {
let mut cfs_v = cfs.to_vec(); let mut cfs_v = cfs.to_vec();
@ -652,8 +652,7 @@ impl DB {
cfs_v.len() as c_int, cfs_v.len() as c_int,
cfnames.as_mut_ptr(), cfnames.as_mut_ptr(),
cfopts.as_mut_ptr(), cfopts.as_mut_ptr(),
cfhandles.as_mut_ptr(), cfhandles.as_mut_ptr(),));
));
} }
for handle in &cfhandles { for handle in &cfhandles {
@ -716,7 +715,7 @@ impl DB {
pub fn destroy<P: AsRef<Path>>(opts: &Options, path: P) -> Result<(), Error> { pub fn destroy<P: AsRef<Path>>(opts: &Options, path: P) -> Result<(), Error> {
let cpath = CString::new(path.as_ref().to_string_lossy().as_bytes()).unwrap(); let cpath = CString::new(path.as_ref().to_string_lossy().as_bytes()).unwrap();
unsafe { unsafe {
ffi_try!(ffi::rocksdb_destroy_db(opts.inner, cpath.as_ptr())); ffi_try!(ffi::rocksdb_destroy_db(opts.inner, cpath.as_ptr(),));
} }
Ok(()) Ok(())
} }
@ -724,7 +723,7 @@ impl DB {
pub fn repair<P: AsRef<Path>>(opts: Options, path: P) -> Result<(), Error> { pub fn repair<P: AsRef<Path>>(opts: Options, path: P) -> Result<(), Error> {
let cpath = CString::new(path.as_ref().to_string_lossy().as_bytes()).unwrap(); let cpath = CString::new(path.as_ref().to_string_lossy().as_bytes()).unwrap();
unsafe { unsafe {
ffi_try!(ffi::rocksdb_repair_db(opts.inner, cpath.as_ptr())); ffi_try!(ffi::rocksdb_repair_db(opts.inner, cpath.as_ptr(),));
} }
Ok(()) Ok(())
} }
@ -735,7 +734,7 @@ impl DB {
pub fn write_opt(&self, batch: WriteBatch, writeopts: &WriteOptions) -> Result<(), Error> { pub fn write_opt(&self, batch: WriteBatch, writeopts: &WriteOptions) -> Result<(), Error> {
unsafe { unsafe {
ffi_try!(ffi::rocksdb_write(self.inner, writeopts.inner, batch.inner)); ffi_try!(ffi::rocksdb_write(self.inner, writeopts.inner, batch.inner,));
} }
Ok(()) Ok(())
} }

@ -34,7 +34,7 @@ pub fn opt_bytes_to_ptr(opt: Option<&[u8]>) -> *const c_char {
} }
macro_rules! ffi_try { macro_rules! ffi_try {
( $($function:ident)::*( $( $arg:expr ),* ) ) => ({ ( $($function:ident)::*( $( $arg:expr,)* ) ) => ({
let mut err: *mut ::libc::c_char = ::std::ptr::null_mut(); let mut err: *mut ::libc::c_char = ::std::ptr::null_mut();
let result = $($function)::*($($arg),*, &mut err); let result = $($function)::*($($arg),*, &mut err);
if !err.is_null() { if !err.is_null() {

Loading…
Cancel
Save