From 00e19012e5c063729cb0555c1592ff625a947119 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 20 Mar 2019 19:10:01 +0100 Subject: [PATCH] server_info: Implement Default and use it. --- src/server_info.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/server_info.rs b/src/server_info.rs index 6f18c7c9..53cef383 100644 --- a/src/server_info.rs +++ b/src/server_info.rs @@ -9,7 +9,7 @@ use crate::util::error::Error; use try_from::TryFrom; /// Structure representing a `http://jabber.org/network/serverinfo` form type. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Default)] pub struct ServerInfo { /// Abuse addresses pub abuse: Vec, @@ -40,14 +40,7 @@ impl TryFrom for ServerInfo { if form.form_type != Some(String::from(ns::SERVER_INFO)) { return Err(Error::ParseError("Wrong FORM_TYPE for form.")); } - let mut server_info = ServerInfo { - abuse: vec![], - admin: vec![], - feedback: vec![], - sales: vec![], - security: vec![], - support: vec![], - }; + let mut server_info = ServerInfo::default(); for field in form.fields { if field.type_ != FieldType::ListMulti { return Err(Error::ParseError("Field is not of the required type."));