aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/rbw
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/rbw')
-rw-r--r--src/bin/rbw/actions.rs5
-rw-r--r--src/bin/rbw/commands.rs30
2 files changed, 16 insertions, 19 deletions
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)
}