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

@ -32,7 +32,7 @@ impl Database {
let mut dbi: ffi::MDB_dbi = 0;
lmdb_result(ffi::mdb_dbi_open(txn, name_ptr, flags, &mut dbi))?;
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
/// environment, or after the database has been closed.
#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn dbi(&self) -> ffi::MDB_dbi {
self.dbi
}

@ -62,6 +62,7 @@ pub struct Environment {
impl Environment {
/// Creates a new builder for specifying options for opening an LMDB environment.
#[allow(clippy::new_ret_no_self)]
pub fn new() -> EnvironmentBuilder {
EnvironmentBuilder {
flags: EnvironmentFlags::empty(),
@ -128,7 +129,7 @@ impl Environment {
/// Retrieves the set of flags which the database is opened with.
///
/// 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 mut flags: c_uint = 0;
unsafe {
@ -428,7 +429,7 @@ impl EnvironmentBuilder {
);
}
Ok(Environment {
env: env,
env,
dbi_open_mutex: Mutex::new(()),
})
}

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

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

Loading…
Cancel
Save