1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 05:19:21 +00:00

Improve code readability

This commit is contained in:
Pierre HUBERT 2022-03-17 19:06:04 +01:00
parent 23fd1fa925
commit b11e085aa2
3 changed files with 4 additions and 4 deletions

View File

@ -49,7 +49,7 @@ impl CommentAPI {
Ok(c_api)
}
pub fn for_list(l: &Vec<Comment>, curr_user_id: &Option<UserID>) -> ResultBoxError<Vec<CommentAPI>> {
pub fn for_list(l: &[Comment], curr_user_id: &Option<UserID>) -> ResultBoxError<Vec<CommentAPI>> {
l.iter().map(|c| Self::new(c, curr_user_id)).collect()
}
}

View File

@ -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<Post>, user_id: Option<UserID>) -> ResultBoxError<Vec<PostAPI>> {
pub fn for_list(l: &[Post], user_id: Option<UserID>) -> ResultBoxError<Vec<PostAPI>> {
l.iter().map(|p| Self::new(p, &user_id)).collect()
}
}

View File

@ -25,7 +25,7 @@ impl SurveyChoiceAPI {
}
}
pub fn for_list(c: &Vec<SurveyChoice>) -> HashMap<u64, SurveyChoiceAPI> {
pub fn for_list(c: &[SurveyChoice]) -> HashMap<u64, SurveyChoiceAPI> {
let mut map = HashMap::with_capacity(c.len());
c.iter().for_each(|c| { map.insert(c.id, Self::new(c)); });
map