Merge pull request #1232 from gwenn/clippy

Fix clippy warnings
This commit is contained in:
gwenn 2022-10-02 11:47:17 +02:00 committed by GitHub
commit 0bd6d6322c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 21 deletions

View File

@ -235,7 +235,7 @@ impl Connection {
table.as_ptr(),
column.as_ptr(),
row_id,
if read_only { 0 } else { 1 },
!read_only as std::os::raw::c_int,
&mut blob,
)
};

View File

@ -115,7 +115,7 @@ impl Connection {
check(ffi::sqlite3_db_config(
c.db(),
config as c_int,
if new_val { 1 } else { 0 },
new_val as c_int,
&mut val,
))?;
Ok(val != 0)

View File

@ -1260,7 +1260,7 @@ mod test {
}
let path_string = path.to_str().unwrap();
let db = Connection::open(&path_string)?;
let db = Connection::open(path_string)?;
let the_answer: Result<i64> = db.query_row("SELECT x FROM foo", [], |r| r.get(0));
assert_eq!(42i64, the_answer?);

View File

@ -369,7 +369,7 @@ mod test {
fn pragma() -> Result<()> {
let db = Connection::open_in_memory()?;
let mut columns = Vec::new();
db.pragma(None, "table_info", &"sqlite_master", |row| {
db.pragma(None, "table_info", "sqlite_master", |row| {
let column: String = row.get(1)?;
columns.push(column);
Ok(())
@ -412,8 +412,8 @@ mod test {
journal_mode,
);
// Sanity checks to ensure the move to a generic `ToSql` wasn't breaking
let mode = db
.pragma_update_and_check(None, "journal_mode", &"OFF", |row| row.get::<_, String>(0))?;
let mode =
db.pragma_update_and_check(None, "journal_mode", "OFF", |row| row.get::<_, String>(0))?;
assert!(mode == "off" || mode == "memory", "mode: {:?}", mode);
let param: &dyn crate::ToSql = &"OFF";
@ -448,7 +448,7 @@ mod test {
#[test]
fn locking_mode() -> Result<()> {
let db = Connection::open_in_memory()?;
let r = db.pragma_update(None, "locking_mode", &"exclusive");
let r = db.pragma_update(None, "locking_mode", "exclusive");
if cfg!(feature = "extra_check") {
r.unwrap_err();
} else {

View File

@ -1409,7 +1409,7 @@ mod test {
// dynamic slice:
db.query_row(
"SELECT ?1, ?2, ?3",
&[&1u8 as &dyn ToSql, &"one", &Some("one")],
[&1u8 as &dyn ToSql, &"one", &Some("one")],
|row| row.get::<_, u8>(0),
)?;
// existing collection:
@ -1494,12 +1494,12 @@ mod test {
#[test]
fn test_utf16_conversion() -> Result<()> {
let db = Connection::open_in_memory()?;
db.pragma_update(None, "encoding", &"UTF-16le")?;
db.pragma_update(None, "encoding", "UTF-16le")?;
let encoding: String = db.pragma_query_value(None, "encoding", |row| row.get(0))?;
assert_eq!("UTF-16le", encoding);
db.execute_batch("CREATE TABLE foo(x TEXT)")?;
let expected = "テスト";
db.execute("INSERT INTO foo(x) VALUES (?)", &[&expected])?;
db.execute("INSERT INTO foo(x) VALUES (?)", [&expected])?;
let actual: String = db.query_row("SELECT x FROM foo", [], |row| row.get(0))?;
assert_eq!(expected, actual);
Ok(())

View File

@ -244,7 +244,7 @@ mod test {
{
for n in out_of_range {
let err = db
.query_row("SELECT ?", &[n], |r| r.get::<_, T>(0))
.query_row("SELECT ?", [n], |r| r.get::<_, T>(0))
.unwrap_err();
match err {
Error::IntegralValueOutOfRange(_, value) => assert_eq!(*n, value),
@ -254,7 +254,7 @@ mod test {
for n in in_range {
assert_eq!(
*n,
db.query_row("SELECT ?", &[n], |r| r.get::<_, T>(0))
db.query_row("SELECT ?", [n], |r| r.get::<_, T>(0))
.unwrap()
.into()
);

View File

@ -153,7 +153,7 @@ mod test {
let db = checked_memory_handle()?;
let v1234 = vec![1u8, 2, 3, 4];
db.execute("INSERT INTO foo(b) VALUES (?)", &[&v1234])?;
db.execute("INSERT INTO foo(b) VALUES (?)", [&v1234])?;
let v: Vec<u8> = db.query_row("SELECT b FROM foo", [], |r| r.get(0))?;
assert_eq!(v, v1234);
@ -165,7 +165,7 @@ mod test {
let db = checked_memory_handle()?;
let empty = vec![];
db.execute("INSERT INTO foo(b) VALUES (?)", &[&empty])?;
db.execute("INSERT INTO foo(b) VALUES (?)", [&empty])?;
let v: Vec<u8> = db.query_row("SELECT b FROM foo", [], |r| r.get(0))?;
assert_eq!(v, empty);
@ -177,7 +177,7 @@ mod test {
let db = checked_memory_handle()?;
let s = "hello, world!";
db.execute("INSERT INTO foo(t) VALUES (?)", &[&s])?;
db.execute("INSERT INTO foo(t) VALUES (?)", [&s])?;
let from: String = db.query_row("SELECT t FROM foo", [], |r| r.get(0))?;
assert_eq!(from, s);
@ -216,8 +216,8 @@ mod test {
let s = Some("hello, world!");
let b = Some(vec![1u8, 2, 3, 4]);
db.execute("INSERT INTO foo(t) VALUES (?)", &[&s])?;
db.execute("INSERT INTO foo(b) VALUES (?)", &[&b])?;
db.execute("INSERT INTO foo(t) VALUES (?)", [&s])?;
db.execute("INSERT INTO foo(b) VALUES (?)", [&b])?;
let mut stmt = db.prepare("SELECT t, b FROM foo ORDER BY ROWID ASC")?;
let mut rows = stmt.query([])?;

View File

@ -41,7 +41,7 @@ mod test {
let data: serde_json::Value = serde_json::from_str(json).unwrap();
db.execute(
"INSERT INTO foo (t, b) VALUES (?, ?)",
&[&data as &dyn ToSql, &json.as_bytes()],
[&data as &dyn ToSql, &json.as_bytes()],
)?;
let t: serde_json::Value = db.query_row("SELECT t FROM foo", [], |r| r.get(0))?;

View File

@ -208,7 +208,7 @@ mod test {
{
let mut stmt = db.prepare("SELECT value from rarray(?);")?;
let rows = stmt.query_map(&[&ptr], |row| row.get::<_, i64>(0))?;
let rows = stmt.query_map([&ptr], |row| row.get::<_, i64>(0))?;
assert_eq!(2, Rc::strong_count(&ptr));
let mut count = 0;
for (i, value) in rows.enumerate() {

View File

@ -457,7 +457,7 @@ impl IndexInfo {
#[inline]
pub fn set_order_by_consumed(&mut self, order_by_consumed: bool) {
unsafe {
(*self.0).orderByConsumed = if order_by_consumed { 1 } else { 0 };
(*self.0).orderByConsumed = order_by_consumed as c_int;
}
}
@ -613,7 +613,7 @@ impl IndexConstraintUsage<'_> {
/// if `omit`, do not code a test for this constraint
#[inline]
pub fn set_omit(&mut self, omit: bool) {
self.0.omit = if omit { 1 } else { 0 };
self.0.omit = omit as std::os::raw::c_uchar;
}
}