bin/taud: cargo clippy

This commit is contained in:
ghassmo
2022-03-28 11:24:22 +04:00
committed by parazyd
parent 3958becf6a
commit d0549ce08b
3 changed files with 12 additions and 12 deletions

View File

@@ -192,7 +192,7 @@ impl JsonRpcInterface {
}
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() {
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<String> = 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<String> = serde_json::from_value(project)?;
task.set_project(&project);
}
@@ -250,7 +250,7 @@ fn from_taud_result(res: TaudResult<Value>, 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,

View File

@@ -17,11 +17,11 @@ pub struct MonthTasks {
}
impl MonthTasks {
pub fn new(task_tks: &Vec<String>, 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)

View File

@@ -148,12 +148,12 @@ impl TaskInfo {
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) {
@@ -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;
len += VarInt(vec.len() as u64).encode(&mut s)?;
for c in vec.iter() {