Clippy pass (cargo clippy -- -D warnings -A clippy::match-ref-pats -A clippy::needless-lifetimes)

Signed-off-by: Victor Porof <victor.porof@gmail.com>
without.crypto
Victor Porof 5 years ago
parent 2acd21c529
commit bca20c45c4
  1. 14
      src/cursor.rs
  2. 3
      src/database.rs
  3. 5
      src/environment.rs
  4. 1
      src/error.rs
  5. 8
      src/transaction.rs

@ -161,7 +161,7 @@ impl<'txn> RoCursor<'txn> {
lmdb_result(ffi::mdb_cursor_open(txn.txn(), db.dbi(), &mut cursor))?; lmdb_result(ffi::mdb_cursor_open(txn.txn(), db.dbi(), &mut cursor))?;
} }
Ok(RoCursor { Ok(RoCursor {
cursor: cursor, cursor,
_marker: PhantomData, _marker: PhantomData,
}) })
} }
@ -203,7 +203,7 @@ impl<'txn> RwCursor<'txn> {
lmdb_result(ffi::mdb_cursor_open(txn.txn(), db.dbi(), &mut cursor))?; lmdb_result(ffi::mdb_cursor_open(txn.txn(), db.dbi(), &mut cursor))?;
} }
Ok(RwCursor { Ok(RwCursor {
cursor: cursor, cursor,
_marker: PhantomData, _marker: PhantomData,
}) })
} }
@ -288,9 +288,9 @@ impl<'txn> Iter<'txn> {
/// Creates a new iterator backed by the given cursor. /// Creates a new iterator backed by the given cursor.
fn new<'t>(cursor: *mut ffi::MDB_cursor, op: c_uint, next_op: c_uint) -> Iter<'t> { fn new<'t>(cursor: *mut ffi::MDB_cursor, op: c_uint, next_op: c_uint) -> Iter<'t> {
Iter::Ok { Iter::Ok {
cursor: cursor, cursor,
op: op, op,
next_op: next_op, next_op,
_marker: PhantomData, _marker: PhantomData,
} }
} }
@ -369,8 +369,8 @@ impl<'txn> IterDup<'txn> {
/// Creates a new iterator backed by the given cursor. /// Creates a new iterator backed by the given cursor.
fn new<'t>(cursor: *mut ffi::MDB_cursor, op: c_uint) -> IterDup<'t> { fn new<'t>(cursor: *mut ffi::MDB_cursor, op: c_uint) -> IterDup<'t> {
IterDup::Ok { IterDup::Ok {
cursor: cursor, cursor,
op: op, op,
_marker: PhantomData, _marker: PhantomData,
} }
} }

@ -32,7 +32,7 @@ impl Database {
let mut dbi: ffi::MDB_dbi = 0; let mut dbi: ffi::MDB_dbi = 0;
lmdb_result(ffi::mdb_dbi_open(txn, name_ptr, flags, &mut dbi))?; lmdb_result(ffi::mdb_dbi_open(txn, name_ptr, flags, &mut dbi))?;
Ok(Database { Ok(Database {
dbi: dbi, dbi,
}) })
} }
@ -46,6 +46,7 @@ impl Database {
/// ///
/// The caller **must** ensure that the handle is not used after the lifetime of the /// The caller **must** ensure that the handle is not used after the lifetime of the
/// environment, or after the database has been closed. /// environment, or after the database has been closed.
#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn dbi(&self) -> ffi::MDB_dbi { pub fn dbi(&self) -> ffi::MDB_dbi {
self.dbi self.dbi
} }

@ -62,6 +62,7 @@ pub struct Environment {
impl Environment { impl Environment {
/// Creates a new builder for specifying options for opening an LMDB environment. /// Creates a new builder for specifying options for opening an LMDB environment.
#[allow(clippy::new_ret_no_self)]
pub fn new() -> EnvironmentBuilder { pub fn new() -> EnvironmentBuilder {
EnvironmentBuilder { EnvironmentBuilder {
flags: EnvironmentFlags::empty(), flags: EnvironmentFlags::empty(),
@ -128,7 +129,7 @@ impl Environment {
/// Retrieves the set of flags which the database is opened with. /// Retrieves the set of flags which the database is opened with.
/// ///
/// The database must belong to to this environment. /// The database must belong to to this environment.
pub fn get_db_flags<'env>(&'env self, db: Database) -> Result<DatabaseFlags> { pub fn get_db_flags(&self, db: Database) -> Result<DatabaseFlags> {
let txn = self.begin_ro_txn()?; let txn = self.begin_ro_txn()?;
let mut flags: c_uint = 0; let mut flags: c_uint = 0;
unsafe { unsafe {
@ -428,7 +429,7 @@ impl EnvironmentBuilder {
); );
} }
Ok(Environment { Ok(Environment {
env: env, env,
dbi_open_mutex: Mutex::new(()), dbi_open_mutex: Mutex::new(()),
}) })
} }

@ -86,6 +86,7 @@ impl Error {
} }
/// Converts an `Error` to the raw error code. /// Converts an `Error` to the raw error code.
#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn to_err_code(&self) -> c_int { pub fn to_err_code(&self) -> c_int {
match *self { match *self {
Error::KeyExist => ffi::MDB_KEYEXIST, Error::KeyExist => ffi::MDB_KEYEXIST,

@ -162,7 +162,7 @@ impl<'env> RoTransaction<'env> {
unsafe { unsafe {
lmdb_result(ffi::mdb_txn_begin(env.env(), ptr::null_mut(), ffi::MDB_RDONLY, &mut txn))?; lmdb_result(ffi::mdb_txn_begin(env.env(), ptr::null_mut(), ffi::MDB_RDONLY, &mut txn))?;
Ok(RoTransaction { Ok(RoTransaction {
txn: txn, txn,
_marker: PhantomData, _marker: PhantomData,
}) })
} }
@ -187,7 +187,7 @@ impl<'env> RoTransaction<'env> {
ffi::mdb_txn_reset(txn) ffi::mdb_txn_reset(txn)
}; };
InactiveTransaction { InactiveTransaction {
txn: txn, txn,
_marker: PhantomData, _marker: PhantomData,
} }
} }
@ -230,7 +230,7 @@ impl<'env> InactiveTransaction<'env> {
lmdb_result(ffi::mdb_txn_renew(txn))? lmdb_result(ffi::mdb_txn_renew(txn))?
}; };
Ok(RoTransaction { Ok(RoTransaction {
txn: txn, txn,
_marker: PhantomData, _marker: PhantomData,
}) })
} }
@ -262,7 +262,7 @@ impl<'env> RwTransaction<'env> {
unsafe { unsafe {
lmdb_result(ffi::mdb_txn_begin(env.env(), ptr::null_mut(), EnvironmentFlags::empty().bits(), &mut txn))?; lmdb_result(ffi::mdb_txn_begin(env.env(), ptr::null_mut(), EnvironmentFlags::empty().bits(), &mut txn))?;
Ok(RwTransaction { Ok(RwTransaction {
txn: txn, txn,
_marker: PhantomData, _marker: PhantomData,
}) })
} }

Loading…
Cancel
Save