aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-02-19 01:05:27 -0500
committerJesse Luehrs <doy@tozt.net>2021-02-19 01:05:27 -0500
commit40f4d51da8c799e3dfb525b99def8f2812689f6c (patch)
treebd9a6687b8c807792f9fcd07da7c21b75ae2f881
parentd8e88421c54d2e74db2b4bd529067393cfbdbc96 (diff)
downloadrbw-40f4d51da8c799e3dfb525b99def8f2812689f6c.tar.gz
rbw-40f4d51da8c799e3dfb525b99def8f2812689f6c.zip
clippy
-rw-r--r--src/api.rs2
-rw-r--r--src/bin/rbw/actions.rs5
-rw-r--r--src/bin/rbw/commands.rs30
-rw-r--r--src/pinentry.rs14
-rw-r--r--src/pwgen.rs10
5 files changed, 29 insertions, 32 deletions
diff --git a/src/api.rs b/src/api.rs
index 77a6ee6..ca92e25 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -1017,7 +1017,7 @@ fn classify_login_error(error_res: &ConnectErrorRes, code: u16) -> Error {
"" => {
// bitwarden_rs returns an empty error and error_description for
// this case, for some reason
- if error_res.error_description == "" {
+ if error_res.error_description.is_empty() {
if let Some(error_model) = error_res.error_model.as_ref() {
let message = error_model.message.as_str().to_string();
match message.as_str() {
diff --git a/src/bin/rbw/actions.rs b/src/bin/rbw/actions.rs
index ec6ba99..75703f9 100644
--- a/src/bin/rbw/actions.rs
+++ b/src/bin/rbw/actions.rs
@@ -34,7 +34,7 @@ pub fn quit() -> anyhow::Result<()> {
.and_then(|p| p.to_str().map(|s| s.to_string())),
action: rbw::protocol::Action::Quit,
})?;
- wait_for_exit(pid)?;
+ wait_for_exit(pid);
Ok(())
}
Err(e) => match e.kind() {
@@ -148,12 +148,11 @@ fn connect() -> anyhow::Result<crate::sock::Sock> {
})
}
-fn wait_for_exit(pid: nix::unistd::Pid) -> anyhow::Result<()> {
+fn wait_for_exit(pid: nix::unistd::Pid) {
loop {
if nix::sys::signal::kill(pid, None).is_err() {
break;
}
std::thread::sleep(std::time::Duration::from_millis(10));
}
- Ok(())
}
diff --git a/src/bin/rbw/commands.rs b/src/bin/rbw/commands.rs
index 3fa30f4..49c44a4 100644
--- a/src/bin/rbw/commands.rs
+++ b/src/bin/rbw/commands.rs
@@ -99,8 +99,8 @@ impl DecryptedCipher {
for field in &self.fields {
displayed |= self.display_field(
- field.name.as_deref().unwrap_or_else(|| "(null)"),
- Some(field.value.as_deref().unwrap_or_else(|| "")),
+ field.name.as_deref().unwrap_or("(null)"),
+ Some(field.value.as_deref().unwrap_or("")),
);
}
@@ -227,12 +227,11 @@ impl DecryptedCipher {
if let Some(given_username) = username {
match &self.data {
- DecryptedData::Login { username, .. } => {
- if let Some(found_username) = username {
- if given_username != found_username {
- return false;
- }
- } else {
+ DecryptedData::Login {
+ username: Some(found_username),
+ ..
+ } => {
+ if given_username != found_username {
return false;
}
}
@@ -273,12 +272,11 @@ impl DecryptedCipher {
if let Some(given_username) = username {
match &self.data {
- DecryptedData::Login { username, .. } => {
- if let Some(found_username) = username {
- if !found_username.contains(given_username) {
- return false;
- }
- } else {
+ DecryptedData::Login {
+ username: Some(found_username),
+ ..
+ } => {
+ if !found_username.contains(given_username) {
return false;
}
}
@@ -1391,14 +1389,14 @@ fn parse_editor(contents: &str) -> (Option<String>, Option<String>) {
let password = lines.next().map(std::string::ToString::to_string);
let mut notes: String = lines
- .skip_while(|line| *line == "")
+ .skip_while(|line| line.is_empty())
.filter(|line| !line.starts_with('#'))
.map(|line| format!("{}\n", line))
.collect();
while notes.ends_with('\n') {
notes.pop();
}
- let notes = if notes == "" { None } else { Some(notes) };
+ let notes = if notes.is_empty() { None } else { Some(notes) };
(password, notes)
}
diff --git a/src/pinentry.rs b/src/pinentry.rs
index a4627c2..69bf92c 100644
--- a/src/pinentry.rs
+++ b/src/pinentry.rs
@@ -86,11 +86,10 @@ where
if ncommands == 1 {
len = 0;
break;
- } else {
- data.copy_within((nl + 1).., 0);
- len -= nl + 1;
- ncommands -= 1;
}
+ data.copy_within((nl + 1).., 0);
+ len -= nl + 1;
+ ncommands -= 1;
} else if data.starts_with(b"D ") {
data.copy_within(2..nl, 0);
len = nl - 2;
@@ -110,11 +109,10 @@ where
return Err(Error::PinentryErrorMessage {
error: error.to_string(),
});
- } else {
- return Err(Error::PinentryErrorMessage {
- error: format!("unknown error ({})", code),
- });
}
+ return Err(Error::PinentryErrorMessage {
+ error: format!("unknown error ({})", code),
+ });
}
None => {
return Err(Error::PinentryErrorMessage {
diff --git a/src/pwgen.rs b/src/pwgen.rs
index fa110d6..dc6808f 100644
--- a/src/pwgen.rs
+++ b/src/pwgen.rs
@@ -18,10 +18,12 @@ pub enum Type {
pub fn pwgen(ty: Type, len: usize) -> String {
if ty == Type::Diceware {
- let mut config = chbs::config::BasicConfig::default();
- config.words = len;
- config.capitalize_first = chbs::probability::Probability::Never;
- config.capitalize_words = chbs::probability::Probability::Never;
+ let config = chbs::config::BasicConfig {
+ words: len,
+ capitalize_first: chbs::probability::Probability::Never,
+ capitalize_words: chbs::probability::Probability::Never,
+ ..chbs::config::BasicConfig::default()
+ };
return config.to_scheme().generate();
}