From b11e085aa21adc498c838a016eb10f9c0fc15d0d Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 17 Mar 2022 19:06:04 +0100 Subject: [PATCH] Improve code readability --- src/api_data/comment_api.rs | 2 +- src/api_data/post_api.rs | 4 ++-- src/api_data/survey_choice_api.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/api_data/comment_api.rs b/src/api_data/comment_api.rs index 524a67c..9c46934 100644 --- a/src/api_data/comment_api.rs +++ b/src/api_data/comment_api.rs @@ -49,7 +49,7 @@ impl CommentAPI { Ok(c_api) } - pub fn for_list(l: &Vec, curr_user_id: &Option) -> ResultBoxError> { + pub fn for_list(l: &[Comment], curr_user_id: &Option) -> ResultBoxError> { l.iter().map(|c| Self::new(c, curr_user_id)).collect() } } \ No newline at end of file diff --git a/src/api_data/post_api.rs b/src/api_data/post_api.rs index a9e3aae..a0b504b 100644 --- a/src/api_data/post_api.rs +++ b/src/api_data/post_api.rs @@ -114,7 +114,7 @@ impl PostAPI { PostKind::POST_KIND_COUNTDOWN(time_end) => post.time_end = Some(*time_end), PostKind::POST_KIND_SURVEY => - post.data_survey = Some(SurveyAPI::new(&survey_helper::get_info(p.id)?, user.clone())?), + post.data_survey = Some(SurveyAPI::new(&survey_helper::get_info(p.id)?, *user)?), PostKind::POST_KIND_YOUTUBE(id) => { post.file_path = Some(id.clone()); @@ -130,7 +130,7 @@ impl PostAPI { } /// Turn a list of posts into an API entry - pub fn for_list(l: &Vec, user_id: Option) -> ResultBoxError> { + pub fn for_list(l: &[Post], user_id: Option) -> ResultBoxError> { l.iter().map(|p| Self::new(p, &user_id)).collect() } } \ No newline at end of file diff --git a/src/api_data/survey_choice_api.rs b/src/api_data/survey_choice_api.rs index 769f835..af41d8e 100644 --- a/src/api_data/survey_choice_api.rs +++ b/src/api_data/survey_choice_api.rs @@ -25,7 +25,7 @@ impl SurveyChoiceAPI { } } - pub fn for_list(c: &Vec) -> HashMap { + pub fn for_list(c: &[SurveyChoice]) -> HashMap { let mut map = HashMap::with_capacity(c.len()); c.iter().for_each(|c| { map.insert(c.id, Self::new(c)); }); map