diff options
| author | Andrew Aylett <andrew@aylett.co.uk> | 2025-01-07 20:15:53 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-07 20:15:53 +0000 |
| commit | cea5f840ef0281c8ccf9cc0250b2d07082847038 (patch) | |
| tree | 312e936a2bf622150702372c49acfeafefa272a4 | |
| parent | chore: Remove unneeded dependencies (#2523) (diff) | |
| download | atuin-cea5f840ef0281c8ccf9cc0250b2d07082847038.zip | |
style: Avoid calling `unwrap()` when we don't have to (#2519)
Use `if let` rather than `is_some()` followed by `unwrap()`, and coerce
errors instead of calling `unwrap()` when available.
| -rw-r--r-- | crates/atuin-client/src/settings.rs | 2 | ||||
| -rw-r--r-- | crates/atuin/src/command/client/search.rs | 12 |
2 files changed, 7 insertions, 7 deletions
diff --git a/crates/atuin-client/src/settings.rs b/crates/atuin-client/src/settings.rs index 10c804fa..4c2b10ab 100644 --- a/crates/atuin-client/src/settings.rs +++ b/crates/atuin-client/src/settings.rs @@ -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)), diff --git a/crates/atuin/src/command/client/search.rs b/crates/atuin/src/command/client/search.rs index b8dfe659..b0e503ad 100644 --- a/crates/atuin/src/command/client/search.rs +++ b/crates/atuin/src/command/client/search.rs @@ -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; |
