cargo fix --all

* it added "dyn" to trait objects
* it changed "..." in patterns to "..="

cargo --version says: "cargo 1.37.0-nightly (545f35425 2019-05-23)"
This commit is contained in:
Scott Lamb
2019-06-14 08:47:11 -07:00
parent 7dd98bb76a
commit 7fe9d34655
22 changed files with 83 additions and 83 deletions

View File

@@ -54,7 +54,7 @@ pub struct Args<'a> {
fn set_journal_mode(conn: &rusqlite::Connection, requested: &str) -> Result<(), Error> {
assert!(!requested.contains(';')); // quick check for accidental sql injection.
let actual = conn.query_row(&format!("pragma journal_mode = {}", requested), &[] as &[&ToSql],
let actual = conn.query_row(&format!("pragma journal_mode = {}", requested), &[] as &[&dyn ToSql],
|row| row.get::<_, String>(0))?;
info!("...database now in journal_mode {} (requested {}).", actual, requested);
Ok(())
@@ -71,7 +71,7 @@ pub fn run(args: &Args, conn: &mut rusqlite::Connection) -> Result<(), Error> {
{
assert_eq!(upgraders.len(), db::EXPECTED_VERSION as usize);
let old_ver =
conn.query_row("select max(id) from version", &[] as &[&ToSql],
conn.query_row("select max(id) from version", &[] as &[&dyn ToSql],
|row| row.get(0))?;
if old_ver > db::EXPECTED_VERSION {
bail!("Database is at version {}, later than expected {}",
@@ -88,7 +88,7 @@ pub fn run(args: &Args, conn: &mut rusqlite::Connection) -> Result<(), Error> {
tx.execute(r#"
insert into version (id, unix_time, notes)
values (?, cast(strftime('%s', 'now') as int32), ?)
"#, &[&(ver + 1) as &ToSql, &UPGRADE_NOTES])?;
"#, &[&(ver + 1) as &dyn ToSql, &UPGRADE_NOTES])?;
tx.commit()?;
}
}
@@ -97,7 +97,7 @@ pub fn run(args: &Args, conn: &mut rusqlite::Connection) -> Result<(), Error> {
// compiles the SQLite3 amalgamation with -DSQLITE_DEFAULT_FOREIGN_KEYS=1). Ensure it's
// always on. Note that our foreign keys are immediate rather than deferred, so we have to
// be careful about the order of operations during the upgrade.
conn.execute("pragma foreign_keys = on", &[] as &[&ToSql])?;
conn.execute("pragma foreign_keys = on", &[] as &[&dyn ToSql])?;
// WAL is the preferred journal mode for normal operation; it reduces the number of syncs
// without compromising safety.

View File

@@ -142,7 +142,7 @@ fn fill_recording(tx: &rusqlite::Transaction) -> Result<HashMap<i32, CameraState
insert into recording_playback values (:composite_id, :sample_file_uuid, :sample_file_sha1,
:video_index)
"#)?;
let mut rows = select.query(&[] as &[&ToSql])?;
let mut rows = select.query(&[] as &[&dyn ToSql])?;
let mut camera_state: HashMap<i32, CameraState> = HashMap::new();
while let Some(row) = rows.next()? {
let camera_id: i32 = row.get(0)?;
@@ -216,7 +216,7 @@ fn fill_camera(tx: &rusqlite::Transaction, camera_state: HashMap<i32, CameraStat
insert into camera values (:id, :uuid, :short_name, :description, :host, :username, :password,
:main_rtsp_path, :sub_rtsp_path, :retain_bytes, :next_recording_id)
"#)?;
let mut rows = select.query(&[] as &[&ToSql])?;
let mut rows = select.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let id: i32 = row.get(0)?;
let uuid: Vec<u8> = row.get(1)?;

View File

@@ -122,7 +122,7 @@ pub fn run(args: &super::Args, tx: &rusqlite::Transaction) -> Result<(), Error>
tx.execute(r#"
insert into sample_file_dir (path, uuid, last_complete_open_id)
values (?, ?, ?)
"#, &[&sample_file_path as &ToSql, &dir_uuid_bytes, &open_id])?;
"#, &[&sample_file_path as &dyn ToSql, &dir_uuid_bytes, &open_id])?;
tx.execute_batch(r#"
drop table reserved_sample_files;
@@ -298,7 +298,7 @@ fn verify_dir_contents(sample_file_path: &str, tx: &rusqlite::Transaction) -> Re
from
(select count(*) as c from recording) a,
(select count(*) as c from reserved_sample_files) b;
"#, &[] as &[&ToSql], |r| r.get(0))?;
"#, &[] as &[&dyn ToSql], |r| r.get(0))?;
let mut files = ::fnv::FnvHashSet::with_capacity_and_hasher(n as usize, Default::default());
for e in fs::read_dir(sample_file_path)? {
let e = e?;
@@ -329,7 +329,7 @@ fn verify_dir_contents(sample_file_path: &str, tx: &rusqlite::Transaction) -> Re
// Iterate through the database and check that everything has a matching file.
{
let mut stmt = tx.prepare(r"select sample_file_uuid from recording_playback")?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let uuid: crate::db::FromSqlUuid = row.get(0)?;
if !files.remove(&uuid.0) {
@@ -339,7 +339,7 @@ fn verify_dir_contents(sample_file_path: &str, tx: &rusqlite::Transaction) -> Re
}
let mut stmt = tx.prepare(r"select uuid from reserved_sample_files")?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let uuid: crate::db::FromSqlUuid = row.get(0)?;
files.remove(&uuid.0);
@@ -366,7 +366,7 @@ fn fix_video_sample_entry(tx: &rusqlite::Transaction) -> Result<(), Error> {
let mut insert = tx.prepare(r#"
insert into video_sample_entry values (:id, :sha1, :width, :height, :rfc6381_codec, :data)
"#)?;
let mut rows = select.query(&[] as &[&ToSql])?;
let mut rows = select.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let data: Vec<u8> = row.get(4)?;
insert.execute_named(&[

View File

@@ -57,7 +57,7 @@ fn open_sample_file_dir(tx: &rusqlite::Transaction) -> Result<Arc<dir::SampleFil
sample_file_dir s
join open o on (s.last_complete_open_id = o.id)
cross join meta m
"#, &[] as &[&ToSql], |row| {
"#, &[] as &[&dyn ToSql], |row| {
Ok((row.get(0)?,
row.get(1)?,
row.get(2)?,
@@ -84,7 +84,7 @@ pub fn run(_args: &super::Args, tx: &rusqlite::Transaction) -> Result<(), Error>
from
recording_playback
"#)?;
let mut rows = stmt.query(&[] as &[&ToSql])?;
let mut rows = stmt.query(&[] as &[&dyn ToSql])?;
while let Some(row) = rows.next()? {
let id = db::CompositeId(row.get(0)?);
let sample_file_uuid: FromSqlUuid = row.get(1)?;