Skip to content

Commit 5b82a14

Browse files
brian6932replydev
authored andcommitted
chore: Clippy warnings
1 parent 942f4b0 commit 5b82a14

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

src/interface/handlers/main_window.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,20 +123,20 @@ 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+
#[allow(clippy::manual_saturating_arithmetic)]
134+
Some(counter.checked_add(1).unwrap_or(u64::MAX))
135+
} else {
136+
Some(counter.saturating_sub(1))
137+
};
138+
app.database.mark_modified();
139+
app.tick(true);
140140
}
141141
}
142142

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)