ghassmo 4 жил өмнө
parent
commit
d0549ce08b

+ 4 - 4
bin/taud/src/jsonrpc.rs

@@ -192,7 +192,7 @@ impl JsonRpcInterface {
     }
     }
 
 
     fn check_data_for_update(&self, task_id: &Value, data: &Value) -> TaudResult<TaskInfo> {
     fn check_data_for_update(&self, task_id: &Value, data: &Value) -> TaudResult<TaskInfo> {
-        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() {
         if !data.is_object() {
             return Err(TaudError::InvalidData("Invalid task's data".into()))
             return Err(TaudError::InvalidData("Invalid task's data".into()))
@@ -226,13 +226,13 @@ impl JsonRpcInterface {
 
 
         if data.contains_key("assign") {
         if data.contains_key("assign") {
             let assign = data.get("assign").unwrap().clone();
             let assign = data.get("assign").unwrap().clone();
-            let assign = serde_json::from_value(assign)?;
+            let assign: Vec<String> = serde_json::from_value(assign)?;
             task.set_assign(&assign);
             task.set_assign(&assign);
         }
         }
 
 
         if data.contains_key("project") {
         if data.contains_key("project") {
             let project = data.get("project").unwrap().clone();
             let project = data.get("project").unwrap().clone();
-            let project = serde_json::from_value(project)?;
+            let project: Vec<String> = serde_json::from_value(project)?;
             task.set_project(&project);
             task.set_project(&project);
         }
         }
 
 
@@ -250,7 +250,7 @@ fn from_taud_result(res: TaudResult<Value>, id: Value) -> JsonResult {
                 id,
                 id,
             )),
             )),
             TaudError::InvalidData(e) | TaudError::SerdeJsonError(e) => {
             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(
             TaudError::InvalidDueTime => JsonResult::Err(jsonerr(
                 ErrorCode::InvalidParams,
                 ErrorCode::InvalidParams,

+ 3 - 3
bin/taud/src/month_tasks.rs

@@ -17,11 +17,11 @@ pub struct MonthTasks {
 }
 }
 
 
 impl MonthTasks {
 impl MonthTasks {
-    pub fn new(task_tks: &Vec<String>, settings: &Settings) -> Self {
+    pub fn new(task_tks: &[String], settings: &Settings) -> Self {
         Self {
         Self {
             created_at: get_current_time(),
             created_at: get_current_time(),
             settings: settings.clone(),
             settings: settings.clone(),
-            task_tks: task_tks.clone(),
+            task_tks: task_tks.to_owned(),
         }
         }
     }
     }
 
 
@@ -76,7 +76,7 @@ impl MonthTasks {
                 Ok(mt)
                 Ok(mt)
             }
             }
             Err(_) => {
             Err(_) => {
-                let mut mt = Self::new(&vec![], settings);
+                let mut mt = Self::new(&[], settings);
                 mt.set_date(date);
                 mt.set_date(date);
                 mt.save()?;
                 mt.save()?;
                 Ok(mt)
                 Ok(mt)

+ 5 - 5
bin/taud/src/task_info.rs

@@ -148,12 +148,12 @@ impl TaskInfo {
         self.desc = desc.into();
         self.desc = desc.into();
     }
     }
 
 
-    pub fn set_assign(&mut self, assign: &Vec<String>) {
-        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<String>) {
-        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) {
     pub fn set_comment(&mut self, c: Comment) {
@@ -226,7 +226,7 @@ impl Decodable for TaskAssigns {
     }
     }
 }
 }
 
 
-fn encode_vec<T: Encodable, S: io::Write>(vec: &Vec<T>, mut s: S) -> darkfi::Result<usize> {
+fn encode_vec<T: Encodable, S: io::Write>(vec: &[T], mut s: S) -> darkfi::Result<usize> {
     let mut len = 0;
     let mut len = 0;
     len += VarInt(vec.len() as u64).encode(&mut s)?;
     len += VarInt(vec.len() as u64).encode(&mut s)?;
     for c in vec.iter() {
     for c in vec.iter() {