From 287937ac631683316a24ab0e88e4c9225a207fd7 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 17 Mar 2022 18:34:42 +0100 Subject: [PATCH] Improve code readability --- src/api_data/res_get_security_questions.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/api_data/res_get_security_questions.rs b/src/api_data/res_get_security_questions.rs index 3ab5685..4452fdf 100644 --- a/src/api_data/res_get_security_questions.rs +++ b/src/api_data/res_get_security_questions.rs @@ -7,14 +7,15 @@ use crate::data::user::User; #[derive(Serialize)] pub struct ResGetSecurityQuestions { - questions: Vec + questions: Vec, } impl ResGetSecurityQuestions { pub fn new(user: &User) -> ResGetSecurityQuestions { - let mut questions = Vec::new(); - questions.push(user.security_question_1.clone().unwrap_or(String::new())); - questions.push(user.security_question_2.clone().unwrap_or(String::new())); + let questions = vec![ + user.security_question_1.clone().unwrap_or_default(), + user.security_question_2.clone().unwrap_or_default(), + ]; ResGetSecurityQuestions { questions } }