aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJoris2022-11-21 15:39:03 +0100
committerJoris2022-11-21 15:39:03 +0100
commitf1b134f51254e82f352a06aae9557cc4570627de (patch)
treee33fc88b3a601904059163a60d9b7b2f2b54dbe4 /src/gui
parenta8422f43da46c010ec58666035ad0a6c2254c1ff (diff)
Use f-strings when convenient
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/mod.rs26
-rw-r--r--src/gui/util.rs2
2 files changed, 11 insertions, 17 deletions
diff --git a/src/gui/mod.rs b/src/gui/mod.rs
index 719f39a..858b30d 100644
--- a/src/gui/mod.rs
+++ b/src/gui/mod.rs
@@ -63,10 +63,10 @@ pub fn start(conn: &Connection, term: &mut Term, events: &Events, deck_name: &st
},
None => {
let message = match db::next_ready(conn) {
- Some(ready) => format!(
- "Prochaine carte disponible dans {}.",
- time::pp_duration(ready - now)
- ),
+ Some(ready) => {
+ let duration = time::pp_duration(ready - now);
+ format!("Prochaine carte disponible dans {duration}.")
+ },
None => "Aucune carte n’est disponible. Votre deck est-il vide ?".to_string(),
};
let _ = message::show(term, events, &title, &message, true);
@@ -82,18 +82,12 @@ fn title(deck_name: &str, answers: i32, available_cards: i32) -> String {
if answers == 0 && available_cards == 0 {
deck_name.to_string()
} else if available_cards == 0 {
- format!(
- "{} ({} / {})",
- deck_name,
- answers,
- answers + available_cards
- )
+ let from = answers;
+ let to = answers + available_cards;
+ format!("{deck_name} ({from} / {to})")
} else {
- format!(
- "{} ({} / {})",
- deck_name,
- answers + 1,
- answers + available_cards
- )
+ let from = answers + 1;
+ let to = answers + available_cards;
+ format!("{deck_name} ({from} / {to})")
}
}
diff --git a/src/gui/util.rs b/src/gui/util.rs
index 2314aba..c62c755 100644
--- a/src/gui/util.rs
+++ b/src/gui/util.rs
@@ -17,5 +17,5 @@ pub fn center_vertically(chunk: Rect, text: &str) -> String {
let chunk_inner_lines: usize = (chunk.height - 2).into();
let blank_lines = chunk_inner_lines - text_lines;
let newlines = "\n".repeat(blank_lines / 2);
- format!("{}{}", newlines, text)
+ format!("{newlines}{text}")
}