Appease clippy
This commit is contained in:
parent
eeb21af841
commit
233b28a1b9
19 changed files with 49 additions and 52 deletions
|
@ -20,7 +20,7 @@ unsafe impl Send for Connection {}
|
|||
impl Connection {
|
||||
pub(crate) fn open(uri: &str, persistent: bool) -> Result<Self> {
|
||||
let mut connection = Self {
|
||||
sqlite3: 0 as *mut _,
|
||||
sqlite3: ptr::null_mut(),
|
||||
persistent,
|
||||
write: RefCell::new(true),
|
||||
_sqlite: PhantomData,
|
||||
|
@ -32,7 +32,7 @@ impl Connection {
|
|||
CString::new(uri)?.as_ptr(),
|
||||
&mut connection.sqlite3,
|
||||
flags,
|
||||
0 as *const _,
|
||||
ptr::null(),
|
||||
);
|
||||
|
||||
// Turn on extended error codes
|
||||
|
@ -97,7 +97,7 @@ impl Connection {
|
|||
let remaining_sql_str = remaining_sql.to_str().unwrap().trim();
|
||||
remaining_sql_str != ";" && !remaining_sql_str.is_empty()
|
||||
} {
|
||||
let mut raw_statement = 0 as *mut sqlite3_stmt;
|
||||
let mut raw_statement = ptr::null_mut::<sqlite3_stmt>();
|
||||
let mut remaining_sql_ptr = ptr::null();
|
||||
sqlite3_prepare_v2(
|
||||
self.sqlite3,
|
||||
|
|
|
@ -48,7 +48,7 @@ impl<'a> Statement<'a> {
|
|||
.trim();
|
||||
remaining_sql_str != ";" && !remaining_sql_str.is_empty()
|
||||
} {
|
||||
let mut raw_statement = 0 as *mut sqlite3_stmt;
|
||||
let mut raw_statement = ptr::null_mut::<sqlite3_stmt>();
|
||||
let mut remaining_sql_ptr = ptr::null();
|
||||
sqlite3_prepare_v2(
|
||||
connection.sqlite3,
|
||||
|
@ -101,7 +101,7 @@ impl<'a> Statement<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn bind_index_with(&self, index: i32, bind: impl Fn(&*mut sqlite3_stmt) -> ()) -> Result<()> {
|
||||
fn bind_index_with(&self, index: i32, bind: impl Fn(&*mut sqlite3_stmt)) -> Result<()> {
|
||||
let mut any_succeed = false;
|
||||
unsafe {
|
||||
for raw_statement in self.raw_statements.iter() {
|
||||
|
@ -133,7 +133,7 @@ impl<'a> Statement<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn column_blob<'b>(&'b mut self, index: i32) -> Result<&'b [u8]> {
|
||||
pub fn column_blob(&mut self, index: i32) -> Result<&[u8]> {
|
||||
let index = index as c_int;
|
||||
let pointer = unsafe { sqlite3_column_blob(self.current_statement(), index) };
|
||||
|
||||
|
@ -217,7 +217,7 @@ impl<'a> Statement<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn column_text<'b>(&'b mut self, index: i32) -> Result<&'b str> {
|
||||
pub fn column_text(&mut self, index: i32) -> Result<&str> {
|
||||
let index = index as c_int;
|
||||
let pointer = unsafe { sqlite3_column_text(self.current_statement(), index) };
|
||||
|
||||
|
|
|
@ -114,12 +114,12 @@ impl<M: Migrator> ThreadSafeConnection<M> {
|
|||
let mut queues = QUEUES.write();
|
||||
if !queues.contains_key(&self.uri) {
|
||||
let mut write_queue_constructor =
|
||||
write_queue_constructor.unwrap_or(background_thread_queue());
|
||||
write_queue_constructor.unwrap_or_else(background_thread_queue);
|
||||
queues.insert(self.uri.clone(), write_queue_constructor());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
false
|
||||
}
|
||||
|
||||
pub fn builder(uri: &str, persistent: bool) -> ThreadSafeConnectionBuilder<M> {
|
||||
|
@ -187,10 +187,9 @@ impl<M: Migrator> ThreadSafeConnection<M> {
|
|||
*connection.write.get_mut() = false;
|
||||
|
||||
if let Some(initialize_query) = connection_initialize_query {
|
||||
connection.exec(initialize_query).expect(&format!(
|
||||
"Initialize query failed to execute: {}",
|
||||
initialize_query
|
||||
))()
|
||||
connection.exec(initialize_query).unwrap_or_else(|_| {
|
||||
panic!("Initialize query failed to execute: {}", initialize_query)
|
||||
})()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
|
@ -225,7 +224,7 @@ impl<M: Migrator> Clone for ThreadSafeConnection<M> {
|
|||
Self {
|
||||
uri: self.uri.clone(),
|
||||
persistent: self.persistent,
|
||||
connection_initialize_query: self.connection_initialize_query.clone(),
|
||||
connection_initialize_query: self.connection_initialize_query,
|
||||
connections: self.connections.clone(),
|
||||
_migrator: PhantomData,
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::{
|
|||
|
||||
impl Connection {
|
||||
pub fn exec<'a>(&'a self, query: &str) -> Result<impl 'a + FnMut() -> Result<()>> {
|
||||
let mut statement = Statement::prepare(&self, query)?;
|
||||
let mut statement = Statement::prepare(self, query)?;
|
||||
Ok(move || statement.exec())
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ impl Connection {
|
|||
&'a self,
|
||||
query: &str,
|
||||
) -> Result<impl 'a + FnMut(B) -> Result<()>> {
|
||||
let mut statement = Statement::prepare(&self, query)?;
|
||||
let mut statement = Statement::prepare(self, query)?;
|
||||
Ok(move |bindings| statement.with_bindings(bindings)?.exec())
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ impl Connection {
|
|||
&'a self,
|
||||
query: &str,
|
||||
) -> Result<impl 'a + FnMut() -> Result<Vec<C>>> {
|
||||
let mut statement = Statement::prepare(&self, query)?;
|
||||
let mut statement = Statement::prepare(self, query)?;
|
||||
Ok(move || statement.rows::<C>())
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ impl Connection {
|
|||
&'a self,
|
||||
query: &str,
|
||||
) -> Result<impl 'a + FnMut(B) -> Result<Vec<C>>> {
|
||||
let mut statement = Statement::prepare(&self, query)?;
|
||||
let mut statement = Statement::prepare(self, query)?;
|
||||
Ok(move |bindings| statement.with_bindings(bindings)?.rows::<C>())
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ impl Connection {
|
|||
&'a self,
|
||||
query: &str,
|
||||
) -> Result<impl 'a + FnMut() -> Result<Option<C>>> {
|
||||
let mut statement = Statement::prepare(&self, query)?;
|
||||
let mut statement = Statement::prepare(self, query)?;
|
||||
Ok(move || statement.maybe_row::<C>())
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ impl Connection {
|
|||
&'a self,
|
||||
query: &str,
|
||||
) -> Result<impl 'a + FnMut(B) -> Result<Option<C>>> {
|
||||
let mut statement = Statement::prepare(&self, query)?;
|
||||
let mut statement = Statement::prepare(self, query)?;
|
||||
Ok(move |bindings| {
|
||||
statement
|
||||
.with_bindings(bindings)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue