Skip to content

Commit 1d3cb1f

Browse files
committed
chore: resolve clippy warnings
1 parent 16a05d1 commit 1d3cb1f

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

src/arguments/add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl SubcommandExecutor for AddArgs {
8080

8181
fn get_from_args(matches: AddArgs) -> color_eyre::Result<OTPElement> {
8282
let secret = rpassword::prompt_password("Insert the secret: ").map_err(ErrReport::from)?;
83-
map_args_to_code(secret, matches).map_err(ErrReport::from)
83+
map_args_to_code(secret, matches)
8484
}
8585

8686
fn map_args_to_code(secret: String, matches: AddArgs) -> Result<OTPElement> {

src/arguments/extract.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ impl SubcommandExecutor for ExtractArgs {
4848
}
4949

5050
fn filter_extract(args: &ExtractArgs, index: usize, code: &OTPElement) -> bool {
51-
let match_by_index = args.index.map_or(true, |i| i == index);
51+
let match_by_index = args.index.is_none_or(|i| i == index);
5252

53-
let match_by_issuer = args.issuer.as_ref().map_or(true, |issuer| {
54-
code.issuer.to_lowercase() == issuer.to_lowercase()
55-
});
53+
let match_by_issuer = args
54+
.issuer
55+
.as_ref()
56+
.is_none_or(|issuer| code.issuer.to_lowercase() == issuer.to_lowercase());
5657

57-
let match_by_label = args.label.as_ref().map_or(true, |label| {
58-
code.label.to_lowercase() == label.to_lowercase()
59-
});
58+
let match_by_label = args
59+
.label
60+
.as_ref()
61+
.is_none_or(|label| code.label.to_lowercase() == label.to_lowercase());
6062

6163
match_by_index && match_by_issuer && match_by_label
6264
}

src/arguments/passwd.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use clap::Args;
2-
use color_eyre::eyre::ErrReport;
32
use zeroize::Zeroize;
43

54
use crate::{otp::otp_element::OTPDatabase, utils};
@@ -12,9 +11,7 @@ pub struct PasswdArgs;
1211
impl SubcommandExecutor for PasswdArgs {
1312
fn run_command(self, mut database: OTPDatabase) -> color_eyre::Result<OTPDatabase> {
1413
let mut new_password = utils::verified_password("New password: ", 8);
15-
database
16-
.save_with_pw(&new_password)
17-
.map_err(ErrReport::from)?;
14+
database.save_with_pw(&new_password)?;
1815
new_password.zeroize();
1916
Ok(database)
2017
}

src/path.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ fn get_default_db_path() -> PathBuf {
3636
let home_path = home_dir().map(|path| path.join(HOME_PATH));
3737

3838
data_dir()
39-
.map(PathBuf::from)
4039
.map(|p| p.join(XDG_PATH))
4140
.inspect(|xdg| {
4241
if !xdg.exists() {

0 commit comments

Comments
 (0)