Skip to content

Commit

Permalink
Rename functions (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyu08 committed Jan 22, 2024
1 parent f0972b3 commit 2388552
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/file/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct History {
executed_targets: Vec<String>,
}

pub fn read_history(content: String) -> Result<Vec<(PathBuf, Vec<String>)>> {
pub fn parse_history(content: String) -> Result<Vec<(PathBuf, Vec<String>)>> {
let histories: Histories = toml::from_str(&content)?;

let mut result: Vec<(PathBuf, Vec<String>)> = Vec::new();
Expand All @@ -42,7 +42,7 @@ pub fn read_history(content: String) -> Result<Vec<(PathBuf, Vec<String>)>> {
Ok(result)
}

pub fn write_history(
pub fn store_history(
history_directory_path: PathBuf,
history_file_name: String,
histories_tuple: Vec<(PathBuf, Vec<String>)>,
Expand Down Expand Up @@ -113,13 +113,13 @@ executed-targets = ["run", "echo1"]
match case.expect {
Ok(v) => assert_eq!(
v,
read_history(case.content).unwrap(),
parse_history(case.content).unwrap(),
"\nFailed: 🚨{:?}🚨\n",
case.title,
),
Err(e) => assert_eq!(
e.to_string(),
read_history(case.content).unwrap_err().to_string(),
parse_history(case.content).unwrap_err().to_string(),
"\nFailed: 🚨{:?}🚨\n",
case.title,
),
Expand Down
4 changes: 2 additions & 2 deletions src/usecase/fzf_make/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl Model<'_> {
Err(_) => return Histories::new(makefile_path, vec![]), // NOTE: Show error message on message pane https://github.com/kyu08/fzf-make/issues/152
Ok(c) => c,
};
let histories = match toml::read_history(content.to_string()) {
let histories = match toml::parse_history(content.to_string()) {
Err(_) => vec![], // NOTE: Show error message on message pane https://github.com/kyu08/fzf-make/issues/152
Ok(h) => h,
};
Expand Down Expand Up @@ -431,7 +431,7 @@ fn update(model: &mut Model, message: Option<Message>) {

if let (Some((dir, file_name)), Some(h)) = (history_file_path(), &model.histories) {
// TODO: handle error
let _ = toml::write_history(dir, file_name, h.to_tuple());
let _ = toml::store_history(dir, file_name, h.to_tuple());
}
}

Expand Down

0 comments on commit 2388552

Please sign in to comment.