aboutsummaryrefslogtreecommitdiffstats
path: root/src/command
diff options
context:
space:
mode:
Diffstat (limited to 'src/command')
-rw-r--r--src/command/client/history.rs6
-rw-r--r--src/command/client/search/history_list.rs13
2 files changed, 7 insertions, 12 deletions
diff --git a/src/command/client/history.rs b/src/command/client/history.rs
index 6a78adc9..c45ee0c8 100644
--- a/src/command/client/history.rs
+++ b/src/command/client/history.rs
@@ -136,10 +136,8 @@ impl Cmd {
// It's better for atuin to silently fail here and attempt to
// store whatever is ran, than to throw an error to the terminal
- let cwd = match env::current_dir() {
- Ok(dir) => dir.display().to_string(),
- Err(_) => String::from(""),
- };
+ let cwd = env::current_dir()
+ .map_or_else(|_| String::new(), |dir| dir.display().to_string());
let h = History::new(chrono::Utc::now(), command, cwd, -1, -1, None, None);
diff --git a/src/command/client/search/history_list.rs b/src/command/client/search/history_list.rs
index e4d8ee6b..fda1098f 100644
--- a/src/command/client/search/history_list.rs
+++ b/src/command/client/search/history_list.rs
@@ -35,14 +35,11 @@ impl<'a> StatefulWidget for HistoryList<'a> {
type State = ListState;
fn render(mut self, area: Rect, buf: &mut Buffer, state: &mut Self::State) {
- let list_area = match self.block.take() {
- Some(b) => {
- let inner_area = b.inner(area);
- b.render(area, buf);
- inner_area
- }
- None => area,
- };
+ let list_area = self.block.take().map_or(area, |b| {
+ let inner_area = b.inner(area);
+ b.render(area, buf);
+ inner_area
+ });
if list_area.width < 1 || list_area.height < 1 || self.history.is_empty() {
return;