cargo clippy --fix

This switches to inlining variable names into format args. clippy
now suggests this syntax, and I like it.
This commit is contained in:
Scott Lamb
2023-01-29 15:01:19 -08:00
parent 159e426943
commit a9430464b6
31 changed files with 119 additions and 162 deletions

View File

@@ -339,8 +339,7 @@ fn press_delete(siv: &mut Cursive, db: &Arc<db::Database>, id: i32, name: String
})
} else {
views::Dialog::text(format!(
"Delete camera {}? This camera has no recorded video.",
name
"Delete camera {name}? This camera has no recorded video."
))
.button("Delete", {
let db = db.clone();
@@ -381,7 +380,7 @@ fn confirm_deletion(siv: &mut Cursive, db: &Arc<db::Database>, id: i32, to_delet
}
if let Err(e) = lower_retention(db, zero_limits) {
siv.add_layer(
views::Dialog::text(format!("Unable to delete recordings: {}", e))
views::Dialog::text(format!("Unable to delete recordings: {e}"))
.title("Error")
.dismiss_button("Abort"),
);
@@ -417,7 +416,7 @@ fn actually_delete(siv: &mut Cursive, db: &Arc<db::Database>, id: i32) {
};
if let Err(e) = result {
siv.add_layer(
views::Dialog::text(format!("Unable to delete camera: {}", e))
views::Dialog::text(format!("Unable to delete camera: {e}"))
.title("Error")
.dismiss_button("Abort"),
);

View File

@@ -48,7 +48,7 @@ fn update_limits_inner(model: &Model) -> Result<(), Error> {
fn update_limits(model: &Model, siv: &mut Cursive) {
if let Err(e) = update_limits_inner(model) {
siv.add_layer(
views::Dialog::text(format!("Unable to update limits: {}", e))
views::Dialog::text(format!("Unable to update limits: {e}"))
.dismiss_button("Back")
.title("Error"),
);
@@ -79,7 +79,7 @@ fn edit_limit(model: &RefCell<Model>, siv: &mut Cursive, id: i32, content: &str)
}
if new_value.is_none() != stream.retain.is_none() {
model.errors += if new_value.is_none() { 1 } else { -1 };
siv.find_name::<views::TextView>(&format!("{}_ok", id))
siv.find_name::<views::TextView>(&format!("{id}_ok"))
.unwrap()
.set_content(if new_value.is_none() { "*" } else { " " });
}
@@ -139,7 +139,7 @@ fn actually_delete(model: &RefCell<Model>, siv: &mut Cursive) {
}
if let Err(e) = writer::lower_retention(model.db.clone(), model.dir_id, &new_limits[..]) {
siv.add_layer(
views::Dialog::text(format!("Unable to delete excess video: {}", e))
views::Dialog::text(format!("Unable to delete excess video: {e}"))
.title("Error")
.dismiss_button("Abort"),
);
@@ -281,7 +281,7 @@ fn delete_dir_dialog(db: &Arc<db::Database>, siv: &mut Cursive, dir_id: i32) {
fn delete_dir(db: &Arc<db::Database>, siv: &mut Cursive, dir_id: i32) {
if let Err(e) = db.lock().delete_sample_file_dir(dir_id) {
siv.add_layer(
views::Dialog::text(format!("Unable to delete dir id {}: {}", dir_id, e))
views::Dialog::text(format!("Unable to delete dir id {dir_id}: {e}"))
.dismiss_button("Back")
.title("Error"),
);
@@ -381,7 +381,7 @@ fn edit_dir_dialog(db: &Arc<db::Database>, siv: &mut Cursive, dir_id: i32) {
)
.child(
views::TextView::new("")
.with_name(format!("{}_ok", id))
.with_name(format!("{id}_ok"))
.fixed_width(1),
),
);

View File

@@ -61,7 +61,7 @@ fn press_edit(siv: &mut Cursive, db: &Arc<db::Database>, id: Option<i32>, pw: Pa
};
if let Err(e) = result {
siv.add_layer(
views::Dialog::text(format!("Unable to apply change: {}", e))
views::Dialog::text(format!("Unable to apply change: {e}"))
.title("Error")
.dismiss_button("Abort"),
);
@@ -76,7 +76,7 @@ fn press_edit(siv: &mut Cursive, db: &Arc<db::Database>, id: Option<i32>, pw: Pa
fn press_delete(siv: &mut Cursive, db: &Arc<db::Database>, id: i32, name: String) {
siv.add_layer(
views::Dialog::text(format!("Delete user {}?", name))
views::Dialog::text(format!("Delete user {name}?"))
.button("Delete", {
let db = db.clone();
move |s| actually_delete(s, &db, id)
@@ -94,7 +94,7 @@ fn actually_delete(siv: &mut Cursive, db: &Arc<db::Database>, id: i32) {
};
if let Err(e) = result {
siv.add_layer(
views::Dialog::text(format!("Unable to delete user: {}", e))
views::Dialog::text(format!("Unable to delete user: {e}"))
.title("Error")
.dismiss_button("Abort"),
);
@@ -193,7 +193,7 @@ fn edit_user_dialog(db: &Arc<db::Database>, siv: &mut Cursive, item: Option<i32>
] {
let mut checkbox = views::Checkbox::new();
checkbox.set_checked(*b);
perms.add_child(name, checkbox.with_name(format!("perm_{}", name)));
perms.add_child(name, checkbox.with_name(format!("perm_{name}")));
}
layout.add_child(perms);

View File

@@ -105,7 +105,7 @@ pub fn run(args: Args) -> Result<i32, Error> {
f.sync_all()?;
println!("Wrote cookie to {}", p.display());
} else {
println!("s={}", encoded);
println!("s={encoded}");
}
Ok(0)
}