From d0549ce08be4a21b84366dd2f96d513383ffb986 Mon Sep 17 00:00:00 2001 From: ghassmo Date: Mon, 28 Mar 2022 11:24:22 +0400 Subject: [PATCH] bin/taud: cargo clippy --- bin/taud/src/jsonrpc.rs | 8 ++++---- bin/taud/src/month_tasks.rs | 6 +++--- bin/taud/src/task_info.rs | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bin/taud/src/jsonrpc.rs b/bin/taud/src/jsonrpc.rs index 01b1e5c56..b8e0c98e4 100644 --- a/bin/taud/src/jsonrpc.rs +++ b/bin/taud/src/jsonrpc.rs @@ -192,7 +192,7 @@ impl JsonRpcInterface { } fn check_data_for_update(&self, task_id: &Value, data: &Value) -> TaudResult { - let mut task: TaskInfo = self.load_task_by_id(&task_id)?; + let mut task: TaskInfo = self.load_task_by_id(task_id)?; if !data.is_object() { return Err(TaudError::InvalidData("Invalid task's data".into())) @@ -226,13 +226,13 @@ impl JsonRpcInterface { if data.contains_key("assign") { let assign = data.get("assign").unwrap().clone(); - let assign = serde_json::from_value(assign)?; + let assign: Vec = serde_json::from_value(assign)?; task.set_assign(&assign); } if data.contains_key("project") { let project = data.get("project").unwrap().clone(); - let project = serde_json::from_value(project)?; + let project: Vec = serde_json::from_value(project)?; task.set_project(&project); } @@ -250,7 +250,7 @@ fn from_taud_result(res: TaudResult, id: Value) -> JsonResult { id, )), TaudError::InvalidData(e) | TaudError::SerdeJsonError(e) => { - JsonResult::Err(jsonerr(ErrorCode::InvalidParams, Some(e.to_string()), id)) + JsonResult::Err(jsonerr(ErrorCode::InvalidParams, Some(e), id)) } TaudError::InvalidDueTime => JsonResult::Err(jsonerr( ErrorCode::InvalidParams, diff --git a/bin/taud/src/month_tasks.rs b/bin/taud/src/month_tasks.rs index b15bb80e3..99ef3d358 100644 --- a/bin/taud/src/month_tasks.rs +++ b/bin/taud/src/month_tasks.rs @@ -17,11 +17,11 @@ pub struct MonthTasks { } impl MonthTasks { - pub fn new(task_tks: &Vec, settings: &Settings) -> Self { + pub fn new(task_tks: &[String], settings: &Settings) -> Self { Self { created_at: get_current_time(), settings: settings.clone(), - task_tks: task_tks.clone(), + task_tks: task_tks.to_owned(), } } @@ -76,7 +76,7 @@ impl MonthTasks { Ok(mt) } Err(_) => { - let mut mt = Self::new(&vec![], settings); + let mut mt = Self::new(&[], settings); mt.set_date(date); mt.save()?; Ok(mt) diff --git a/bin/taud/src/task_info.rs b/bin/taud/src/task_info.rs index c28fadffe..723990c0d 100644 --- a/bin/taud/src/task_info.rs +++ b/bin/taud/src/task_info.rs @@ -148,12 +148,12 @@ impl TaskInfo { self.desc = desc.into(); } - pub fn set_assign(&mut self, assign: &Vec) { - self.assign = TaskAssigns(assign.clone()); + pub fn set_assign(&mut self, assign: &[String]) { + self.assign = TaskAssigns(assign.to_owned()); } - pub fn set_project(&mut self, project: &Vec) { - self.project = TaskProjects(project.clone()); + pub fn set_project(&mut self, project: &[String]) { + self.project = TaskProjects(project.to_owned()); } pub fn set_comment(&mut self, c: Comment) { @@ -226,7 +226,7 @@ impl Decodable for TaskAssigns { } } -fn encode_vec(vec: &Vec, mut s: S) -> darkfi::Result { +fn encode_vec(vec: &[T], mut s: S) -> darkfi::Result { let mut len = 0; len += VarInt(vec.len() as u64).encode(&mut s)?; for c in vec.iter() {