Skip to content

Commit a6eb121

Browse files
committed
Merge pull request #110 from Frederick888/clippy into master
* clippy: style: Fix unnecessary_unwrap style: Fix mismatched_lifetime_syntaxes
2 parents 6ec804e + 66de8a9 commit a6eb121

3 files changed

Lines changed: 14 additions & 20 deletions

File tree

src/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,13 +435,13 @@ impl Config {
435435
}
436436

437437
#[cfg(not(feature = "encryption"))]
438-
pub fn get_encryption_key(&self) -> Result<std::cell::Ref<Option<AesKey>>> {
438+
pub fn get_encryption_key(&self) -> Result<std::cell::Ref<'_, Option<AesKey>>> {
439439
error!("Enable encryption to use this feature");
440440
Err(anyhow!("Encryption is not enabled in this build"))
441441
}
442442

443443
#[cfg(feature = "encryption")]
444-
pub fn get_encryption_key(&self) -> Result<std::cell::Ref<Option<AesKey>>> {
444+
pub fn get_encryption_key(&self) -> Result<std::cell::Ref<'_, Option<AesKey>>> {
445445
if self.encryption_key.borrow().is_some() {
446446
return Ok(self.encryption_key.borrow());
447447
}
@@ -631,7 +631,7 @@ impl Encryption {
631631
}
632632

633633
#[cfg(feature = "encryption")]
634-
fn get_response(&self) -> Result<std::cell::Ref<Option<AesKey>>> {
634+
fn get_response(&self) -> Result<std::cell::Ref<'_, Option<AesKey>>> {
635635
match self {
636636
#[cfg(not(feature = "yubikey"))]
637637
Encryption::ChallengeResponse { .. } => {

src/keepassxc/messages/structs.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,17 @@ where
7474
);
7575
};
7676
response_wrapper.log();
77-
if response_wrapper.message.is_some() && response_wrapper.nonce.is_some() {
78-
let (message, nonce) = (
79-
response_wrapper.message.unwrap(),
80-
response_wrapper.nonce.unwrap(),
81-
);
82-
let decrypted_response_json = to_decrypted_json(message, nonce)?;
83-
let response: R = serde_json::from_str(&decrypted_response_json)?;
84-
Ok((response, decrypted_response_json))
85-
} else {
86-
Err(KeePassError {
77+
match (&response_wrapper.message, &response_wrapper.nonce) {
78+
(Some(message), Some(nonce)) => {
79+
let decrypted_response_json = to_decrypted_json(message, nonce)?;
80+
let response: R = serde_json::from_str(&decrypted_response_json)?;
81+
Ok((response, decrypted_response_json))
82+
}
83+
_ => Err(KeePassError {
8784
message: response_wrapper.error_message(),
8885
response: response_wrapper,
8986
}
90-
.into())
87+
.into()),
9188
}
9289
}
9390

@@ -608,7 +605,7 @@ impl GetDatabaseGroupsResponse {
608605
&self.groups.groups
609606
}
610607

611-
pub fn get_flat_groups(&self) -> Vec<FlatGroup> {
608+
pub fn get_flat_groups(&self) -> Vec<FlatGroup<'_>> {
612609
self.get_groups()
613610
.iter()
614611
.map(|g| g.get_flat_groups(vec![]))

src/utils/callers.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,8 @@ impl CurrentCaller {
5252
.ok_or_else(|| anyhow!("Failed to determine parent process path"))?;
5353
info!("Parent process path: {}", ppath.to_string_lossy());
5454
let canonical_ppath = ppath.canonicalize();
55-
if canonical_ppath.is_ok() {
56-
info!(
57-
"Canonical parent process path: {}",
58-
canonical_ppath.as_ref().unwrap().to_string_lossy()
59-
);
55+
if let Ok(p) = &canonical_ppath {
56+
info!("Canonical parent process path: {}", p.to_string_lossy());
6057
} else {
6158
warn!("Failed to determine canonical parent process path");
6259
}

0 commit comments

Comments
 (0)