From 59872a1850b53d6084dfc4d3c559e28679bdbd45 Mon Sep 17 00:00:00 2001 From: gwenn Date: Sat, 2 Apr 2016 17:16:17 +0200 Subject: [PATCH] Fix clippy warnings --- src/vtab/csvtab.rs | 7 +++---- src/vtab/int_array.rs | 1 + src/vtab/mod.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/vtab/csvtab.rs b/src/vtab/csvtab.rs index 1137a35..2be7315 100644 --- a/src/vtab/csvtab.rs +++ b/src/vtab/csvtab.rs @@ -2,7 +2,6 @@ extern crate csv; use std::ffi::CStr; use std::fs::File; -use std::mem; use std::path::Path; use std::result; use std::str; @@ -52,7 +51,7 @@ impl VTab for CSVTab { args: &[*const libc::c_char]) -> Result { if args.len() < 4 { - return Err(Error::ModuleError(format!("no CSV file specified"))); + return Err(Error::ModuleError("no CSV file specified".to_owned())); } // pull out name of csv file (remove quotes) let mut c_filename = unsafe { CStr::from_ptr(args[3]).to_bytes() }; @@ -104,13 +103,13 @@ impl VTab for CSVTab { } if cols.is_empty() { - return Err(Error::ModuleError(format!("no column name specified"))); + return Err(Error::ModuleError("no column name specified".to_owned())); } let mut sql = String::from("CREATE TABLE x("); for (i, col) in cols.iter().enumerate() { if col.is_empty() { - return Err(Error::ModuleError(format!("no column name found"))); + return Err(Error::ModuleError("no column name found".to_owned())); } sql.push('"'); sql.push_str(col); diff --git a/src/vtab/int_array.rs b/src/vtab/int_array.rs index 82a87b1..ef1f6d2 100644 --- a/src/vtab/int_array.rs +++ b/src/vtab/int_array.rs @@ -63,6 +63,7 @@ impl VTab for IntArrayVTab { } } +#[derive(Default)] #[repr(C)] struct IntArrayVTabCursor { /// Base class diff --git a/src/vtab/mod.rs b/src/vtab/mod.rs index 4ed298d..9388aa1 100644 --- a/src/vtab/mod.rs +++ b/src/vtab/mod.rs @@ -130,7 +130,7 @@ pub fn declare_vtab(db: *mut ffi::sqlite3, sql: &str) -> Result<()> { } /// Escape double-quote (`"`) character occurences by doubling them (`""`). -pub fn escape_double_quote<'a>(identifier: &'a str) -> Cow<'a, str> { +pub fn escape_double_quote(identifier: &str) -> Cow { if identifier.contains('"') { // escape quote by doubling them Owned(identifier.replace("\"", "\"\"")) @@ -216,7 +216,7 @@ unsafe extern "C" fn $best_index(vtab: *mut ffi::sqlite3_vtab, } unsafe extern "C" fn $destroy(vtab: *mut ffi::sqlite3_vtab) -> libc::c_int { let vtab = vtab as *mut $vtab; - let _: Box<$vtab> = Box::from_raw(mem::transmute(vtab)); + let _: Box<$vtab> = Box::from_raw(vtab); ffi::SQLITE_OK } @@ -246,7 +246,7 @@ unsafe extern "C" fn $open(vtab: *mut ffi::sqlite3_vtab, } unsafe extern "C" fn $close(cursor: *mut ffi::sqlite3_vtab_cursor) -> libc::c_int { let cr = cursor as *mut $cursor; - let _: Box<$cursor> = Box::from_raw(mem::transmute(cr)); + let _: Box<$cursor> = Box::from_raw(cr); ffi::SQLITE_OK }