Skip to content

Commit

Permalink
style: Avoid calling unwrap() when we don't have to (#2519)
Browse files Browse the repository at this point in the history
Use `if let` rather than `is_some()` followed by `unwrap()`, and coerce
errors instead of calling `unwrap()` when available.
  • Loading branch information
andrewaylett authored Jan 7, 2025
1 parent 80c4184 commit cea5f84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion crates/atuin-client/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ impl Settings {

match parse_duration(self.sync_frequency.as_str()) {
Ok(d) => {
let d = time::Duration::try_from(d).unwrap();
let d = time::Duration::try_from(d)?;
Ok(OffsetDateTime::now_utc() - Settings::last_sync()? >= d)
}
Err(e) => Err(eyre!("failed to check sync: {}", e)),
Expand Down
12 changes: 6 additions & 6 deletions crates/atuin/src/command/client/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,14 @@ impl Cmd {
return Ok(());
}

if self.search_mode.is_some() {
settings.search_mode = self.search_mode.unwrap();
if let Some(search_mode) = self.search_mode {
settings.search_mode = search_mode;
}
if self.filter_mode.is_some() {
settings.filter_mode = self.filter_mode;
if let Some(filter_mode) = self.filter_mode {
settings.filter_mode = Some(filter_mode);
}
if self.inline_height.is_some() {
settings.inline_height = self.inline_height.unwrap();
if let Some(inline_height) = self.inline_height {
settings.inline_height = inline_height;
}

settings.shell_up_key_binding = self.shell_up_key_binding;
Expand Down

0 comments on commit cea5f84

Please sign in to comment.