xmpp-parsers: Simplify MucUser’s code

We can derive Default directly, and then implement new() based on it.

skip-changelog: Internal change.
This commit is contained in:
Link Mauve 2026-06-10 13:05:00 +02:00
commit e95313eedb

View file

@ -284,7 +284,7 @@ pub struct Decline {
} }
/// The main muc#user element. /// The main muc#user element.
#[derive(FromXml, AsXml, Debug, PartialEq, Clone)] #[derive(FromXml, AsXml, Debug, Default, PartialEq, Clone)]
#[xml(namespace = ns::MUC_USER, name = "x")] #[xml(namespace = ns::MUC_USER, name = "x")]
pub struct MucUser { pub struct MucUser {
/// List of statuses applying to this item. /// List of statuses applying to this item.
@ -304,21 +304,10 @@ pub struct MucUser {
pub decline: Option<Decline>, pub decline: Option<Decline>,
} }
impl Default for MucUser {
fn default() -> Self {
Self::new()
}
}
impl MucUser { impl MucUser {
/// Creates an empty MucUser /// Creates an empty MucUser
pub fn new() -> MucUser { pub fn new() -> MucUser {
MucUser { MucUser::default()
status: vec![],
items: vec![],
invite: None,
decline: None,
}
} }
/// Set statuses for this MucUser /// Set statuses for this MucUser
@ -423,12 +412,7 @@ mod tests {
let elem: Element = "<x xmlns='http://jabber.org/protocol/muc#user'/>" let elem: Element = "<x xmlns='http://jabber.org/protocol/muc#user'/>"
.parse() .parse()
.unwrap(); .unwrap();
let muc = MucUser { let muc = MucUser::new();
status: vec![],
items: vec![],
invite: None,
decline: None,
};
let elem2 = muc.into(); let elem2 = muc.into();
assert_eq!(elem, elem2); assert_eq!(elem, elem2);
} }