diff --git a/src/api_data/data_conservation_settings_api.rs b/src/api_data/data_conservation_settings_api.rs index 3f81b33..5a22c11 100644 --- a/src/api_data/data_conservation_settings_api.rs +++ b/src/api_data/data_conservation_settings_api.rs @@ -18,7 +18,7 @@ pub struct DataConservationSettingsAPI { impl DataConservationSettingsAPI { pub fn new(user: &User) -> Self { Self { - inactive_account_lifetime: user.delete_account_after.clone(), + inactive_account_lifetime: user.delete_account_after, notification_lifetime: user.delete_notifications_after, comments_lifetime: user.delete_comments_after, posts_lifetime: user.delete_posts_after, diff --git a/src/api_data/entities_constructor.rs b/src/api_data/entities_constructor.rs index ac92df6..ed99fa9 100644 --- a/src/api_data/entities_constructor.rs +++ b/src/api_data/entities_constructor.rs @@ -9,7 +9,7 @@ pub trait EntitiesConstructor { fn new(i: &Self::Item) -> Self; /// Parse a list of it - fn for_list(l: &Vec) -> Vec + fn for_list(l: &[Self::Item]) -> Vec where Self: std::marker::Sized { l.iter().map(Self::new).collect() } diff --git a/src/api_data/general_settings_api.rs b/src/api_data/general_settings_api.rs index d54d60c..b90d2f6 100644 --- a/src/api_data/general_settings_api.rs +++ b/src/api_data/general_settings_api.rs @@ -40,9 +40,9 @@ impl GeneralSettingsAPI { allow_comunic_mails: user.allow_mails, public_friends_list: user.public_friends_list, public_email: user.is_email_public, - virtual_directory: user.virtual_directory.clone().unwrap_or(String::new()), - personnal_website: user.personal_website.clone().unwrap_or(String::new()), - publicNote: user.public_note.clone().unwrap_or(String::new()), + virtual_directory: user.virtual_directory.clone().unwrap_or_default(), + personnal_website: user.personal_website.clone().unwrap_or_default(), + publicNote: user.public_note.clone().unwrap_or_default(), location: user.location.clone(), } } diff --git a/src/api_data/security_settings_api.rs b/src/api_data/security_settings_api.rs index a571b44..85af34e 100644 --- a/src/api_data/security_settings_api.rs +++ b/src/api_data/security_settings_api.rs @@ -20,10 +20,10 @@ impl SecuritySettingsAPI { pub fn new(user: &User) -> SecuritySettingsAPI { SecuritySettingsAPI { id: user.id.id(), - security_question_1: user.security_question_1.clone().unwrap_or(String::new()), - security_answer_1: user.security_answer_1.clone().unwrap_or(String::new()), - security_question_2: user.security_question_2.clone().unwrap_or(String::new()), - security_answer_2: user.security_answer_2.clone().unwrap_or(String::new()), + security_question_1: user.security_question_1.clone().unwrap_or_default(), + security_answer_1: user.security_answer_1.clone().unwrap_or_default(), + security_question_2: user.security_question_2.clone().unwrap_or_default(), + security_answer_2: user.security_answer_2.clone().unwrap_or_default(), } } } \ No newline at end of file diff --git a/src/api_data/user_like_api.rs b/src/api_data/user_like_api.rs index 4786a05..9a9cb1c 100644 --- a/src/api_data/user_like_api.rs +++ b/src/api_data/user_like_api.rs @@ -27,7 +27,7 @@ impl UserLikeAPI { } } - pub fn for_list(l: &Vec) -> Vec { + pub fn for_list(l: &[UserLike]) -> Vec { l.iter().map(Self::new).collect() } } \ No newline at end of file diff --git a/src/utils/date_utils.rs b/src/utils/date_utils.rs index e5f2e5c..c567127 100644 --- a/src/utils/date_utils.rs +++ b/src/utils/date_utils.rs @@ -28,7 +28,7 @@ pub fn time() -> u64 { pub fn time_to_mysql_date(time: u64) -> String { let utc = Utc.timestamp(time as i64, 0); let str = utc.to_rfc3339(); - (&str[..19]).replace("T", " ") + (&str[..19]).replace('T', " ") } /// Get current Mysql formatted date diff --git a/src/utils/user_data_utils.rs b/src/utils/user_data_utils.rs index 2e69501..56bf4dc 100644 --- a/src/utils/user_data_utils.rs +++ b/src/utils/user_data_utils.rs @@ -48,7 +48,7 @@ pub fn prepare_file_creation(user_id: &UserID, folder: &str) -> ResultBoxError

ResultBoxError { - let sys_dir = user_data_path(&dir); + let sys_dir = user_data_path(dir); if !sys_dir.exists() { return Err(ExecError::boxed_string(format!("Directory {:?} does not exists!", dir)));