Fix clippy warnings (#959)

Fix clippy warnings
This commit is contained in:
gwenn 2021-05-13 08:58:46 +02:00 committed by GitHub
parent e7bb33a99c
commit 1985e78fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 9 deletions

View File

@ -203,8 +203,8 @@ impl Backup<'_, '_> {
to: &'b mut Connection,
to_name: DatabaseName<'_>,
) -> Result<Backup<'a, 'b>> {
let to_name = to_name.to_cstring()?;
let from_name = from_name.to_cstring()?;
let to_name = to_name.as_cstring()?;
let from_name = from_name.as_cstring()?;
let to_db = to.db.borrow_mut().db;

View File

@ -225,7 +225,7 @@ impl Connection {
) -> Result<Blob<'a>> {
let mut c = self.db.borrow_mut();
let mut blob = ptr::null_mut();
let db = db.to_cstring()?;
let db = db.as_cstring()?;
let table = super::str_to_cstring(table)?;
let column = super::str_to_cstring(column)?;
let rc = unsafe {

View File

@ -169,7 +169,7 @@ mod test {
let _ = db2
.query_row("PRAGMA schema_version", [], |row| row.get::<_, i32>(0))
.expect("unexpected error");
assert_eq!(CALLED.load(Ordering::Relaxed), true);
assert!(CALLED.load(Ordering::Relaxed));
child.join().unwrap();
}

View File

@ -883,7 +883,7 @@ mod test {
let result: Result<bool> =
db.query_row("SELECT regexp('l.s[aeiouy]', 'lisa')", [], |r| r.get(0));
assert_eq!(true, result?);
assert!(result?);
let result: Result<i64> = db.query_row(
"SELECT COUNT(*) FROM foo WHERE regexp('l.s[aeiouy]', x) == 1",

View File

@ -310,7 +310,7 @@ pub const TEMP_DB: DatabaseName<'static> = DatabaseName::Temp;
))]
impl DatabaseName<'_> {
#[inline]
fn to_cstring(&self) -> Result<util::SmallCString> {
fn as_cstring(&self) -> Result<util::SmallCString> {
use self::DatabaseName::{Attached, Main, Temp};
match *self {
Main => str_to_cstring("main"),
@ -1016,7 +1016,7 @@ impl InterruptHandle {
#[cfg(feature = "modern_sqlite")] // 3.7.10
unsafe fn db_filename(db: *mut ffi::sqlite3) -> Option<PathBuf> {
let db_name = DatabaseName::Main.to_cstring().unwrap();
let db_name = DatabaseName::Main.as_cstring().unwrap();
let db_filename = ffi::sqlite3_db_filename(db, db_name.as_ptr());
if db_filename.is_null() {
None

View File

@ -40,7 +40,7 @@ impl Session<'_> {
db: &'conn Connection,
name: DatabaseName<'_>,
) -> Result<Session<'conn>> {
let name = name.to_cstring()?;
let name = name.as_cstring()?;
let db = db.db.borrow_mut().db;
@ -161,7 +161,7 @@ impl Session<'_> {
/// Load the difference between tables.
pub fn diff(&mut self, from: DatabaseName<'_>, table: &str) -> Result<()> {
let from = from.to_cstring()?;
let from = from.as_cstring()?;
let table = str_to_cstring(table)?;
let table = table.as_ptr();
unsafe {