Fix clippy warnings

This commit is contained in:
gwenn 2016-04-02 17:16:17 +02:00
parent b802230d56
commit 59872a1850
3 changed files with 7 additions and 7 deletions

View File

@ -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<CSVTabCursor> for CSVTab {
args: &[*const libc::c_char])
-> Result<CSVTab> {
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<CSVTabCursor> 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);

View File

@ -63,6 +63,7 @@ impl VTab<IntArrayVTabCursor> for IntArrayVTab {
}
}
#[derive(Default)]
#[repr(C)]
struct IntArrayVTabCursor {
/// Base class

View File

@ -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<str> {
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
}