Skip to content

Commit cea5f84

Browse files
authored
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.
1 parent 80c4184 commit cea5f84

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

crates/atuin-client/src/settings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ impl Settings {
613613

614614
match parse_duration(self.sync_frequency.as_str()) {
615615
Ok(d) => {
616-
let d = time::Duration::try_from(d).unwrap();
616+
let d = time::Duration::try_from(d)?;
617617
Ok(OffsetDateTime::now_utc() - Settings::last_sync()? >= d)
618618
}
619619
Err(e) => Err(eyre!("failed to check sync: {}", e)),

crates/atuin/src/command/client/search.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ impl Cmd {
172172
return Ok(());
173173
}
174174

175-
if self.search_mode.is_some() {
176-
settings.search_mode = self.search_mode.unwrap();
175+
if let Some(search_mode) = self.search_mode {
176+
settings.search_mode = search_mode;
177177
}
178-
if self.filter_mode.is_some() {
179-
settings.filter_mode = self.filter_mode;
178+
if let Some(filter_mode) = self.filter_mode {
179+
settings.filter_mode = Some(filter_mode);
180180
}
181-
if self.inline_height.is_some() {
182-
settings.inline_height = self.inline_height.unwrap();
181+
if let Some(inline_height) = self.inline_height {
182+
settings.inline_height = inline_height;
183183
}
184184

185185
settings.shell_up_key_binding = self.shell_up_key_binding;

0 commit comments

Comments
 (0)