mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 16:29:20 +08:00
Merge pull request #477 from gwenn/lifetime-elision
Lifetime elision in impl
This commit is contained in:
commit
df493bb217
@ -167,7 +167,7 @@ pub struct Backup<'a, 'b> {
|
||||
b: *mut ffi::sqlite3_backup,
|
||||
}
|
||||
|
||||
impl<'a, 'b> Backup<'a, 'b> {
|
||||
impl Backup<'_, '_> {
|
||||
/// Attempt to create a new handle that will allow backups from `from` to
|
||||
/// `to`. Note that `to` is a `&mut` - this is because SQLite forbids any
|
||||
/// API calls on the destination of a backup while the backup is taking
|
||||
@ -177,7 +177,7 @@ impl<'a, 'b> Backup<'a, 'b> {
|
||||
///
|
||||
/// Will return `Err` if the underlying `sqlite3_backup_init` call returns
|
||||
/// `NULL`.
|
||||
pub fn new(from: &'a Connection, to: &'b mut Connection) -> Result<Backup<'a, 'b>> {
|
||||
pub fn new<'a, 'b>(from: &'a Connection, to: &'b mut Connection) -> Result<Backup<'a, 'b>> {
|
||||
Backup::new_with_names(from, DatabaseName::Main, to, DatabaseName::Main)
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ impl<'a, 'b> Backup<'a, 'b> {
|
||||
///
|
||||
/// Will return `Err` if the underlying `sqlite3_backup_init` call returns
|
||||
/// `NULL`.
|
||||
pub fn new_with_names(
|
||||
pub fn new_with_names<'a, 'b>(
|
||||
from: &'a Connection,
|
||||
from_name: DatabaseName<'_>,
|
||||
to: &'b mut Connection,
|
||||
@ -294,7 +294,7 @@ impl<'a, 'b> Backup<'a, 'b> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> Drop for Backup<'a, 'b> {
|
||||
impl Drop for Backup<'_, '_> {
|
||||
fn drop(&mut self) {
|
||||
unsafe { ffi::sqlite3_backup_finish(self.b) };
|
||||
}
|
||||
|
10
src/blob.rs
10
src/blob.rs
@ -111,7 +111,7 @@ impl Connection {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> Blob<'conn> {
|
||||
impl Blob<'_> {
|
||||
/// Move a BLOB handle to a new row.
|
||||
///
|
||||
/// # Failure
|
||||
@ -151,7 +151,7 @@ impl<'conn> Blob<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> io::Read for Blob<'conn> {
|
||||
impl io::Read for Blob<'_> {
|
||||
/// Read data from a BLOB incrementally. Will return Ok(0) if the end of
|
||||
/// the blob has been reached.
|
||||
///
|
||||
@ -175,7 +175,7 @@ impl<'conn> io::Read for Blob<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> io::Write for Blob<'conn> {
|
||||
impl io::Write for Blob<'_> {
|
||||
/// Write data into a BLOB incrementally. Will return `Ok(0)` if the end of
|
||||
/// the blob has been reached; consider using `Write::write_all(buf)`
|
||||
/// if you want to get an error if the entirety of the buffer cannot be
|
||||
@ -208,7 +208,7 @@ impl<'conn> io::Write for Blob<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> io::Seek for Blob<'conn> {
|
||||
impl io::Seek for Blob<'_> {
|
||||
/// Seek to an offset, in bytes, in BLOB.
|
||||
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
|
||||
let pos = match pos {
|
||||
@ -235,7 +235,7 @@ impl<'conn> io::Seek for Blob<'conn> {
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
impl<'conn> Drop for Blob<'conn> {
|
||||
impl Drop for Blob<'_> {
|
||||
fn drop(&mut self) {
|
||||
self.close_();
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ impl<'conn> DerefMut for CachedStatement<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> Drop for CachedStatement<'conn> {
|
||||
impl Drop for CachedStatement<'_> {
|
||||
#[allow(unused_must_use)]
|
||||
fn drop(&mut self) {
|
||||
if let Some(stmt) = self.stmt.take() {
|
||||
@ -88,8 +88,8 @@ impl<'conn> Drop for CachedStatement<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> CachedStatement<'conn> {
|
||||
fn new(stmt: Statement<'conn>, cache: &'conn StatementCache) -> CachedStatement<'conn> {
|
||||
impl CachedStatement<'_> {
|
||||
fn new<'conn>(stmt: Statement<'conn>, cache: &'conn StatementCache) -> CachedStatement<'conn> {
|
||||
CachedStatement {
|
||||
stmt: Some(stmt),
|
||||
cache,
|
||||
|
@ -104,7 +104,7 @@ pub struct Context<'a> {
|
||||
args: &'a [*mut sqlite3_value],
|
||||
}
|
||||
|
||||
impl<'a> Context<'a> {
|
||||
impl Context<'_> {
|
||||
/// Returns the number of arguments to the function.
|
||||
pub fn len(&self) -> usize {
|
||||
self.args.len()
|
||||
@ -146,7 +146,7 @@ impl<'a> Context<'a> {
|
||||
/// # Failure
|
||||
///
|
||||
/// Will panic if `idx` is greater than or equal to `self.len()`.
|
||||
pub fn get_raw(&self, idx: usize) -> ValueRef<'a> {
|
||||
pub fn get_raw(&self, idx: usize) -> ValueRef<'_> {
|
||||
let arg = self.args[idx];
|
||||
unsafe { ValueRef::from_value(arg) }
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ pub enum DatabaseName<'a> {
|
||||
feature = "session",
|
||||
feature = "bundled"
|
||||
))]
|
||||
impl<'a> DatabaseName<'a> {
|
||||
impl DatabaseName<'_> {
|
||||
fn to_cstring(&self) -> Result<CString> {
|
||||
use self::DatabaseName::{Attached, Main, Temp};
|
||||
match *self {
|
||||
|
@ -17,7 +17,7 @@ pub struct LoadExtensionGuard<'conn> {
|
||||
conn: &'conn Connection,
|
||||
}
|
||||
|
||||
impl<'conn> LoadExtensionGuard<'conn> {
|
||||
impl LoadExtensionGuard<'_> {
|
||||
/// Attempt to enable loading extensions. Loading extensions will be
|
||||
/// disabled when this guard goes out of scope. Cannot be meaningfully
|
||||
/// nested.
|
||||
@ -28,7 +28,7 @@ impl<'conn> LoadExtensionGuard<'conn> {
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
impl<'conn> Drop for LoadExtensionGuard<'conn> {
|
||||
impl Drop for LoadExtensionGuard<'_> {
|
||||
fn drop(&mut self) {
|
||||
self.conn.load_extension_disable();
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ impl<'stmt> Rows<'stmt> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'stmt> Drop for Rows<'stmt> {
|
||||
impl Drop for Rows<'_> {
|
||||
fn drop(&mut self) {
|
||||
self.reset();
|
||||
}
|
||||
@ -80,7 +80,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn, T, F> Iterator for MappedRows<'conn, F>
|
||||
impl<T, F> Iterator for MappedRows<'_, F>
|
||||
where
|
||||
F: FnMut(&Row<'_, '_>) -> T,
|
||||
{
|
||||
@ -110,7 +110,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'stmt, T, E, F> Iterator for AndThenRows<'stmt, F>
|
||||
impl<T, E, F> Iterator for AndThenRows<'_, F>
|
||||
where
|
||||
E: convert::From<Error>,
|
||||
F: FnMut(&Row<'_, '_>) -> result::Result<T, E>,
|
||||
@ -245,7 +245,7 @@ impl RowIndex for usize {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> RowIndex for &'a str {
|
||||
impl RowIndex for &'_ str {
|
||||
#[inline]
|
||||
fn idx(&self, stmt: &Statement<'_>) -> Result<usize> {
|
||||
stmt.column_index(*self)
|
||||
|
@ -28,14 +28,17 @@ pub struct Session<'conn> {
|
||||
filter: Option<Box<dyn Fn(&str) -> bool>>,
|
||||
}
|
||||
|
||||
impl<'conn> Session<'conn> {
|
||||
impl Session<'_> {
|
||||
/// Create a new session object
|
||||
pub fn new(db: &'conn Connection) -> Result<Session<'conn>> {
|
||||
pub fn new<'conn>(db: &'conn Connection) -> Result<Session<'conn>> {
|
||||
Session::new_with_name(db, DatabaseName::Main)
|
||||
}
|
||||
|
||||
/// Create a new session object
|
||||
pub fn new_with_name(db: &'conn Connection, name: DatabaseName<'_>) -> Result<Session<'conn>> {
|
||||
pub fn new_with_name<'conn>(
|
||||
db: &'conn Connection,
|
||||
name: DatabaseName<'_>,
|
||||
) -> Result<Session<'conn>> {
|
||||
let name = name.to_cstring()?;
|
||||
|
||||
let db = db.db.borrow_mut().db;
|
||||
@ -196,7 +199,7 @@ impl<'conn> Session<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> Drop for Session<'conn> {
|
||||
impl Drop for Session<'_> {
|
||||
fn drop(&mut self) {
|
||||
if self.filter.is_some() {
|
||||
self.table_filter(None::<fn(&str) -> bool>);
|
||||
@ -292,7 +295,7 @@ pub struct ChangesetIter<'changeset> {
|
||||
item: Option<ChangesetItem>,
|
||||
}
|
||||
|
||||
impl<'changeset> ChangesetIter<'changeset> {
|
||||
impl ChangesetIter<'_> {
|
||||
/// Create an iterator on `input`
|
||||
pub fn start_strm<'input>(input: &'input mut dyn Read) -> Result<ChangesetIter<'input>> {
|
||||
let input_ref = &input;
|
||||
@ -312,7 +315,7 @@ impl<'changeset> ChangesetIter<'changeset> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'changeset> FallibleStreamingIterator for ChangesetIter<'changeset> {
|
||||
impl FallibleStreamingIterator for ChangesetIter<'_> {
|
||||
type Error = crate::error::Error;
|
||||
type Item = ChangesetItem;
|
||||
|
||||
@ -343,7 +346,7 @@ pub struct Operation<'item> {
|
||||
indirect: bool,
|
||||
}
|
||||
|
||||
impl<'item> Operation<'item> {
|
||||
impl Operation<'_> {
|
||||
pub fn table_name(&self) -> &str {
|
||||
self.table_name
|
||||
}
|
||||
@ -361,7 +364,7 @@ impl<'item> Operation<'item> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'changeset> Drop for ChangesetIter<'changeset> {
|
||||
impl Drop for ChangesetIter<'_> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::sqlite3changeset_finalize(self.it);
|
||||
|
@ -21,7 +21,7 @@ pub struct Statement<'conn> {
|
||||
stmt: RawStatement,
|
||||
}
|
||||
|
||||
impl<'conn> Statement<'conn> {
|
||||
impl Statement<'_> {
|
||||
/// Get all the column names in the result set of the prepared statement.
|
||||
pub fn column_names(&self) -> Vec<&str> {
|
||||
let n = self.column_count();
|
||||
@ -234,7 +234,7 @@ impl<'conn> Statement<'conn> {
|
||||
/// # Failure
|
||||
///
|
||||
/// Will return `Err` if binding parameters fails.
|
||||
pub fn query_named<'a>(&'a mut self, params: &[(&str, &dyn ToSql)]) -> Result<Rows<'a>> {
|
||||
pub fn query_named(&mut self, params: &[(&str, &dyn ToSql)]) -> Result<Rows<'_>> {
|
||||
self.check_readonly()?;
|
||||
self.bind_parameters_named(params)?;
|
||||
Ok(Rows::new(self))
|
||||
@ -300,11 +300,11 @@ impl<'conn> Statement<'conn> {
|
||||
/// ## Failure
|
||||
///
|
||||
/// Will return `Err` if binding parameters fails.
|
||||
pub fn query_map_named<'a, T, F>(
|
||||
&'a mut self,
|
||||
pub fn query_map_named<T, F>(
|
||||
&mut self,
|
||||
params: &[(&str, &dyn ToSql)],
|
||||
f: F,
|
||||
) -> Result<MappedRows<'a, F>>
|
||||
) -> Result<MappedRows<'_, F>>
|
||||
where
|
||||
F: FnMut(&Row<'_, '_>) -> T,
|
||||
{
|
||||
@ -368,11 +368,11 @@ impl<'conn> Statement<'conn> {
|
||||
/// ## Failure
|
||||
///
|
||||
/// Will return `Err` if binding parameters fails.
|
||||
pub fn query_and_then_named<'a, T, E, F>(
|
||||
&'a mut self,
|
||||
pub fn query_and_then_named<T, E, F>(
|
||||
&mut self,
|
||||
params: &[(&str, &dyn ToSql)],
|
||||
f: F,
|
||||
) -> Result<AndThenRows<'a, F>>
|
||||
) -> Result<AndThenRows<'_, F>>
|
||||
where
|
||||
E: convert::From<Error>,
|
||||
F: FnMut(&Row<'_, '_>) -> result::Result<T, E>,
|
||||
@ -604,7 +604,7 @@ impl<'conn> Statement<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> Into<RawStatement> for Statement<'conn> {
|
||||
impl Into<RawStatement> for Statement<'_> {
|
||||
fn into(mut self) -> RawStatement {
|
||||
let mut stmt = RawStatement::new(ptr::null_mut());
|
||||
mem::swap(&mut stmt, &mut self.stmt);
|
||||
@ -612,7 +612,7 @@ impl<'conn> Into<RawStatement> for Statement<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> fmt::Debug for Statement<'conn> {
|
||||
impl fmt::Debug for Statement<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let sql = str::from_utf8(self.stmt.sql().to_bytes());
|
||||
f.debug_struct("Statement")
|
||||
@ -623,14 +623,14 @@ impl<'conn> fmt::Debug for Statement<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> Drop for Statement<'conn> {
|
||||
impl Drop for Statement<'_> {
|
||||
#[allow(unused_must_use)]
|
||||
fn drop(&mut self) {
|
||||
self.finalize_();
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> Statement<'conn> {
|
||||
impl Statement<'_> {
|
||||
pub(crate) fn new(conn: &Connection, stmt: RawStatement) -> Statement<'_> {
|
||||
Statement { conn, stmt }
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ pub struct Savepoint<'conn> {
|
||||
committed: bool,
|
||||
}
|
||||
|
||||
impl<'conn> Transaction<'conn> {
|
||||
impl Transaction<'_> {
|
||||
/// Begin a new transaction. Cannot be nested; see `savepoint` for nested
|
||||
/// transactions.
|
||||
/// Even though we don't mutate the connection, we take a `&mut Connection`
|
||||
@ -195,7 +195,7 @@ impl<'conn> Transaction<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> Deref for Transaction<'conn> {
|
||||
impl Deref for Transaction<'_> {
|
||||
type Target = Connection;
|
||||
|
||||
fn deref(&self) -> &Connection {
|
||||
@ -204,13 +204,13 @@ impl<'conn> Deref for Transaction<'conn> {
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
impl<'conn> Drop for Transaction<'conn> {
|
||||
impl Drop for Transaction<'_> {
|
||||
fn drop(&mut self) {
|
||||
self.finish_();
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> Savepoint<'conn> {
|
||||
impl Savepoint<'_> {
|
||||
fn with_depth_and_name<T: Into<String>>(
|
||||
conn: &Connection,
|
||||
depth: u32,
|
||||
@ -308,7 +308,7 @@ impl<'conn> Savepoint<'conn> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'conn> Deref for Savepoint<'conn> {
|
||||
impl Deref for Savepoint<'_> {
|
||||
type Target = Connection;
|
||||
|
||||
fn deref(&self) -> &Connection {
|
||||
@ -317,7 +317,7 @@ impl<'conn> Deref for Savepoint<'conn> {
|
||||
}
|
||||
|
||||
#[allow(unused_must_use)]
|
||||
impl<'conn> Drop for Savepoint<'conn> {
|
||||
impl Drop for Savepoint<'_> {
|
||||
fn drop(&mut self) {
|
||||
self.finish_();
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ where
|
||||
// be converted into Values.
|
||||
macro_rules! from_value(
|
||||
($t:ty) => (
|
||||
impl<'a> From<$t> for ToSqlOutput<'a> {
|
||||
impl From<$t> for ToSqlOutput<'_> {
|
||||
fn from(t: $t) -> Self { ToSqlOutput::Owned(t.into())}
|
||||
}
|
||||
)
|
||||
@ -65,7 +65,7 @@ from_value!(Vec<u8>);
|
||||
#[cfg(feature = "i128_blob")]
|
||||
from_value!(i128);
|
||||
|
||||
impl<'a> ToSql for ToSqlOutput<'a> {
|
||||
impl ToSql for ToSqlOutput<'_> {
|
||||
fn to_sql(&self) -> Result<ToSqlOutput<'_>> {
|
||||
Ok(match *self {
|
||||
ToSqlOutput::Borrowed(v) => ToSqlOutput::Borrowed(v),
|
||||
@ -121,7 +121,7 @@ to_sql_self!(f64);
|
||||
#[cfg(feature = "i128_blob")]
|
||||
to_sql_self!(i128);
|
||||
|
||||
impl<'a, T: ?Sized> ToSql for &'a T
|
||||
impl<T: ?Sized> ToSql for &'_ T
|
||||
where
|
||||
T: ToSql,
|
||||
{
|
||||
@ -169,7 +169,7 @@ impl<T: ToSql> ToSql for Option<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ToSql for Cow<'a, str> {
|
||||
impl ToSql for Cow<'_, str> {
|
||||
fn to_sql(&self) -> Result<ToSqlOutput<'_>> {
|
||||
Ok(ToSqlOutput::from(self.as_ref()))
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ pub enum ValueRef<'a> {
|
||||
Blob(&'a [u8]),
|
||||
}
|
||||
|
||||
impl<'a> ValueRef<'a> {
|
||||
impl ValueRef<'_> {
|
||||
pub fn data_type(&self) -> Type {
|
||||
match *self {
|
||||
ValueRef::Null => Type::Null,
|
||||
@ -69,7 +69,7 @@ impl<'a> ValueRef<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<ValueRef<'a>> for Value {
|
||||
impl From<ValueRef<'_>> for Value {
|
||||
fn from(borrowed: ValueRef<'_>) -> Value {
|
||||
match borrowed {
|
||||
ValueRef::Null => Value::Null,
|
||||
|
@ -337,7 +337,7 @@ impl<'a> Iterator for IndexConstraintIter<'a> {
|
||||
/// WHERE clause constraint
|
||||
pub struct IndexConstraint<'a>(&'a ffi::sqlite3_index_constraint);
|
||||
|
||||
impl<'a> IndexConstraint<'a> {
|
||||
impl IndexConstraint<'_> {
|
||||
/// Column constrained. -1 for ROWID
|
||||
pub fn column(&self) -> c_int {
|
||||
self.0.iColumn
|
||||
@ -357,7 +357,7 @@ impl<'a> IndexConstraint<'a> {
|
||||
/// Information about what parameters to pass to `VTabCursor.filter`.
|
||||
pub struct IndexConstraintUsage<'a>(&'a mut ffi::sqlite3_index_constraint_usage);
|
||||
|
||||
impl<'a> IndexConstraintUsage<'a> {
|
||||
impl IndexConstraintUsage<'_> {
|
||||
/// if `argv_index` > 0, constraint is part of argv to `VTabCursor.filter`
|
||||
pub fn set_argv_index(&mut self, argv_index: c_int) {
|
||||
self.0.argvIndex = argv_index;
|
||||
@ -388,7 +388,7 @@ impl<'a> Iterator for OrderByIter<'a> {
|
||||
/// A column of the ORDER BY clause.
|
||||
pub struct OrderBy<'a>(&'a ffi::sqlite3_index_info_sqlite3_index_orderby);
|
||||
|
||||
impl<'a> OrderBy<'a> {
|
||||
impl OrderBy<'_> {
|
||||
/// Column number
|
||||
pub fn column(&self) -> c_int {
|
||||
self.0.iColumn
|
||||
@ -453,7 +453,7 @@ pub struct Values<'a> {
|
||||
args: &'a [*mut ffi::sqlite3_value],
|
||||
}
|
||||
|
||||
impl<'a> Values<'a> {
|
||||
impl Values<'_> {
|
||||
pub fn len(&self) -> usize {
|
||||
self.args.len()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user