Skip to content

Commit fd6f717

Browse files
authored
fix: mismatched_lifetime_syntaxes & clippy compiler warnings (#584)
Fix various lints from Clippy, from the latest Rust version.
2 parents 8bce751 + eeedbb6 commit fd6f717

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

src/interface/handlers/main_window.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,19 @@ pub(super) fn main_handler(key_event: KeyEvent, app: &mut App) {
123123
}
124124

125125
fn handle_counter_switch(app: &mut App, increment: bool) {
126-
if let Some(selected) = app.table.state.selected() {
127-
if let Some(element) = app.database.mut_element(selected) {
128-
if element.type_ == OTPType::Hotp {
129-
// safe to unwrap because the element type is HOTP
130-
let counter = element.counter.unwrap();
131-
element.counter = if increment {
132-
Some(counter.checked_add(1).unwrap_or(u64::MAX))
133-
} else {
134-
Some(counter.saturating_sub(1))
135-
};
136-
app.database.mark_modified();
137-
app.tick(true);
138-
}
139-
}
126+
if let Some(selected) = app.table.state.selected()
127+
&& let Some(element) = app.database.mut_element(selected)
128+
&& element.type_ == OTPType::Hotp
129+
{
130+
// safe to unwrap because the element type is HOTP
131+
let counter = element.counter.unwrap();
132+
element.counter = if increment {
133+
Some(counter.saturating_add(1))
134+
} else {
135+
Some(counter.saturating_sub(1))
136+
};
137+
app.database.mark_modified();
138+
app.tick(true);
140139
}
141140
}
142141

src/interface/row.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl Row {
2121
+ 1) as u16
2222
}
2323

24-
pub fn cells(&self) -> Vec<Cell> {
24+
pub fn cells(&self) -> Vec<Cell<'_>> {
2525
self.values
2626
.iter()
2727
.map(|c| {

src/path.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@ fn get_default_db_path() -> PathBuf {
3838
data_dir()
3939
.map(|p| p.join(XDG_PATH))
4040
.inspect(|xdg| {
41-
if !xdg.exists() {
42-
if let Some(home) = &home_path {
43-
if home.exists() {
44-
fs::create_dir_all(xdg.parent().unwrap()).expect("Failed to create dir");
45-
fs::copy(home, xdg.as_path())
46-
.expect("Failed on copy from legacy dir to XDG_DATA_HOME");
47-
}
48-
}
41+
if !xdg.exists()
42+
&& let Some(home) = &home_path
43+
&& home.exists()
44+
{
45+
fs::create_dir_all(xdg.parent().unwrap()).expect("Failed to create dir");
46+
fs::copy(home, xdg.as_path())
47+
.expect("Failed on copy from legacy dir to XDG_DATA_HOME");
4948
}
5049
})
5150
.or(home_path)

0 commit comments

Comments
 (0)