aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/mod.rs26
-rw-r--r--src/gui/util.rs2
-rw-r--r--src/main.rs2
-rw-r--r--src/util/event.rs4
-rw-r--r--src/util/time.rs4
5 files changed, 16 insertions, 22 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}")
}
diff --git a/src/main.rs b/src/main.rs
index c2373f4..4ca3822 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -28,7 +28,7 @@ fn main() -> Result<()> {
Ok(()) => Ok(()),
Err(msg) => {
// Show errors in TUI, otherwise they are hidden
- gui::message::show(&mut term, &events, &deck_name, &format!("{}", msg), true)?;
+ gui::message::show(&mut term, &events, &deck_name, &format!("{msg}"), true)?;
Err(msg)
}
}
diff --git a/src/util/event.rs b/src/util/event.rs
index 05d8581..379df99 100644
--- a/src/util/event.rs
+++ b/src/util/event.rs
@@ -45,7 +45,7 @@ impl Events {
let stdin = io::stdin();
for key in stdin.keys().flatten() {
if let Err(err) = tx.send(Event::Input(key)) {
- eprintln!("{}", err);
+ eprintln!("{err}");
return;
}
}
@@ -54,7 +54,7 @@ impl Events {
let tick_handle = {
thread::spawn(move || loop {
if let Err(err) = tx.send(Event::Tick) {
- eprintln!("{}", err);
+ eprintln!("{err}");
break;
}
thread::sleep(config.tick_rate);
diff --git a/src/util/time.rs b/src/util/time.rs
index b8a85e6..679d1b4 100644
--- a/src/util/time.rs
+++ b/src/util/time.rs
@@ -31,9 +31,9 @@ pub fn pp_duration(seconds: u64) -> String {
fn plural(n: u64, str: &str) -> String {
if n <= 1 {
- format!("{} {}", n, str)
+ format!("{n} {str}")
} else {
- format!("{} {}s", n, str)
+ format!("{n} {str}s")
}
}