From 0772669b1dfc45c030890097aecccd4329b3628c Mon Sep 17 00:00:00 2001 From: Evsyukov Denis Anatolyevich Date: Wed, 11 Mar 2020 08:35:56 +0300 Subject: [~] rename hash function to get_sha256 --- src/main.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index ac2fcbc..da2726b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ use std::fs::OpenOptions; use std::io::Write; use std::path::Path; use std::path::PathBuf; + fn main() { let args: Vec = env::args().collect(); let mut opts = Options::new(); @@ -76,11 +77,11 @@ Usage: t [-t DIR] [-l LIST] [options] [TEXT]"; let mut prefixes: HashMap = HashMap::new(); for line in contents.lines() { - tasks.insert(hash(&line.to_string()), line.to_string()); + tasks.insert(get_sha256(&line.to_string()), line.to_string()); } for line in contents_done.lines() { - done.insert(hash(&line.to_string()), line.to_string()); + done.insert(get_sha256(&line.to_string()), line.to_string()); } // fill prefixes @@ -137,7 +138,7 @@ Usage: t [-t DIR] [-l LIST] [options] [TEXT]"; if !matches.free.is_empty() { tasks.remove(&task); let task = matches.free.join(" "); - tasks.insert(hash(&task), task); + tasks.insert(get_sha256(&task), task); write_files(tasks, done, taskpath, donepath, delete_empty); } else { println!("Please provide text for new task."); @@ -152,7 +153,7 @@ Usage: t [-t DIR] [-l LIST] [options] [TEXT]"; // add new task if !matches.free.is_empty() { let task = matches.free.join(" "); - tasks.insert(hash(&task), task); + tasks.insert(get_sha256(&task), task); write_files(tasks, done, taskpath, donepath, delete_empty); return; } @@ -172,7 +173,7 @@ Usage: t [-t DIR] [-l LIST] [options] [TEXT]"; } } -fn hash(str: &str) -> String { +fn get_sha256(str: &str) -> String { let mut hasher = Sha256::new(); hasher.input_str(&str); hasher.result_str() -- cgit v1.2.3