From fbed2862fda127b747718e4ae6f5f36a56f29a51 Mon Sep 17 00:00:00 2001 From: Dieter Eickstaedt Date: Sat, 23 Sep 2023 10:56:55 +0200 Subject: refactor: Duplications reduced in order to align implementations of reading history files (#1247) --- atuin-client/src/import/zsh.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'atuin-client/src/import/zsh.rs') diff --git a/atuin-client/src/import/zsh.rs b/atuin-client/src/import/zsh.rs index 632caff9..a4b03f2d 100644 --- a/atuin-client/src/import/zsh.rs +++ b/atuin-client/src/import/zsh.rs @@ -1,7 +1,7 @@ // import old shell history! // automatically hoover up all that we can find -use std::{fs::File, io::Read, path::PathBuf}; +use std::path::PathBuf; use async_trait::async_trait; use directories::UserDirs; @@ -10,6 +10,7 @@ use time::OffsetDateTime; use super::{get_histpath, unix_byte_lines, Importer, Loader}; use crate::history::History; +use crate::import::read_to_end; #[derive(Debug)] pub struct Zsh { @@ -46,10 +47,7 @@ impl Importer for Zsh { const NAME: &'static str = "zsh"; async fn new() -> Result { - let mut bytes = Vec::new(); - let path = get_histpath(default_histpath)?; - let mut f = File::open(path)?; - f.read_to_end(&mut bytes)?; + let bytes = read_to_end(get_histpath(default_histpath)?)?; Ok(Self { bytes }) } -- cgit v1.3.1