clippy
This commit is contained in:
parent
7c8c13a609
commit
233a263b89
|
@ -333,7 +333,7 @@ fn check_field(
|
|||
}
|
||||
},
|
||||
'R' => {
|
||||
match field.default_value(&config)? {
|
||||
match field.default_value(config)? {
|
||||
Some(value) => {
|
||||
config.set(&key, &value)?;
|
||||
},
|
||||
|
@ -365,12 +365,12 @@ fn group_header(name: &str, description: &str) {
|
|||
println!("{}", style::group(&("=".repeat(name.len() + description.len() + 3))));
|
||||
println!("{} - {}", style::group(name), style::field(description));
|
||||
println!("{}", style::group(&("=".repeat(name.len() + description.len() + 3))));
|
||||
println!("");
|
||||
println!();
|
||||
}
|
||||
|
||||
fn show_group(config: &KV, group: &CfgGroup) {
|
||||
for field in group.fields {
|
||||
show_field(&config, group.name, field);
|
||||
show_field(config, group.name, field);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -473,6 +473,6 @@ fn prompt_multiline() -> String {
|
|||
fn prompt_password() -> String {
|
||||
let pass = rpassword::prompt_password("New password (not shown) : ").unwrap();
|
||||
// disabled echo means the newline also isn't shown
|
||||
println!("");
|
||||
println!();
|
||||
pass
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ fn nth_weekday_of_month(year: i32, month: u32, week_day: Weekday, nth: i32) -> O
|
|||
}
|
||||
while date.month() == month {
|
||||
dates.push(date);
|
||||
date = date + Duration::weeks(1);
|
||||
date += Duration::weeks(1);
|
||||
}
|
||||
// get the right one
|
||||
let index = if nth < 0 { dates.len() as i32 + nth } else { nth - 1 } as usize;
|
||||
|
|
|
@ -92,7 +92,7 @@ impl SimpleEmail {
|
|||
|
||||
impl Email {
|
||||
pub fn new(server: &str, user: &str, pass: &str, is_dry_run: bool) -> Self {
|
||||
let message_id_suffix = user.split('@').next_back().unwrap_or(&server).to_string();
|
||||
let message_id_suffix = user.split('@').next_back().unwrap_or(server).to_string();
|
||||
let credentials = Credentials::new(user.to_string(), pass.to_string());
|
||||
Self { server: server.to_string(), credentials, message_id_suffix, is_dry_run }
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ impl Email {
|
|||
}
|
||||
email = email.message_id(Some(message_id.clone()));
|
||||
let email =
|
||||
if in_reply_to.is_some() { email.in_reply_to(in_reply_to.unwrap()) } else { email }
|
||||
if let Some(in_reply_to) = in_reply_to { email.in_reply_to(in_reply_to) } else { email }
|
||||
.subject(subject)
|
||||
.singlepart(
|
||||
SinglePart::builder().header(header::ContentType::TEXT_PLAIN).body(body),
|
||||
|
|
|
@ -95,7 +95,8 @@ impl KeyValueStore {
|
|||
ON CONFLICT(key) DO NOTHING",
|
||||
params![key, value],
|
||||
)
|
||||
.expect(&format!("Failed to write default at key: {}", key));
|
||||
.map_err(|e| format!("Failed to write default at key {key}: {e}"))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
/// Write a `key`/`value` pair to the DB.
|
||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -352,8 +352,8 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
}
|
||||
|
||||
fn generate_new_pad_for_following_date(
|
||||
config: KV, hedgedoc: HedgeDoc, übernächster_plenumtermin: &String,
|
||||
überübernächster_plenumtermin: &String, kv: &KV,
|
||||
config: KV, hedgedoc: HedgeDoc, übernächster_plenumtermin: &str,
|
||||
überübernächster_plenumtermin: &str, kv: &KV,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
match hedgedoc.create_pad() {
|
||||
Err(e) => println!("Failed to create pad: {}", e),
|
||||
|
@ -399,14 +399,14 @@ fn replace_placeholders(
|
|||
|
||||
fn rotate(future_pad_id: &str, kv: &KV) {
|
||||
let next_plenum_pad = kv.get("zukünftiges-plenumspad").ok();
|
||||
if next_plenum_pad == None {
|
||||
kv.set("zukünftiges-plenumspad", &future_pad_id)
|
||||
.expect("Fehler beim Beschreiben der Datenbank mit neuem Plenumslink!");
|
||||
// Beispiel: aktuelles-plenumspad: Ok(Some("eCH24zXGS9S8Stg5xI3aRg"))
|
||||
} else {
|
||||
kv.set("aktuelles-plenumspad", &next_plenum_pad.unwrap())
|
||||
if let Some(next_plenum_pad) = next_plenum_pad {
|
||||
kv.set("aktuelles-plenumspad", &next_plenum_pad)
|
||||
.expect("Fehler beim Beschreiben der Datenbank mit neuem Plenumslink!"); // Beispiel: aktuelles-plenumspad: Ok(Some("eCH24zXGS9S8Stg5xI3aRg"))
|
||||
kv.set("zukünftiges-plenumspad", &future_pad_id)
|
||||
kv.set("zukünftiges-plenumspad", future_pad_id)
|
||||
.expect("Fehler beim Beschreiben der Datenbank mit neuem Plenumslink!");
|
||||
// Beispiel: aktuelles-plenumspad: Ok(Some("eCH24zXGS9S8Stg5xI3aRg"))
|
||||
} else {
|
||||
kv.set("zukünftiges-plenumspad", future_pad_id)
|
||||
.expect("Fehler beim Beschreiben der Datenbank mit neuem Plenumslink!");
|
||||
// Beispiel: aktuelles-plenumspad: Ok(Some("eCH24zXGS9S8Stg5xI3aRg"))
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ fn do_announcement(
|
|||
topic_count(n_topics, false)
|
||||
);
|
||||
let line1 = if n_topics == 0 {
|
||||
format!( "Es sind bisher leider noch keine Themen zusammengekommen. Wenn am Montag immer noch nix ist, dann fällt das Plenum aus." )
|
||||
"Es sind bisher leider noch keine Themen zusammengekommen. Wenn am Montag immer noch nix ist, dann fällt das Plenum aus.".to_string()
|
||||
} else {
|
||||
format!("Die bisherigen Themen für das Plenum sind:\n\n{toc}")
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue