From b6796d54e6e4eca02d1ceb53da03aa1bd0c6a945 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 12 Jan 2019 22:51:02 +0100 Subject: [PATCH] roster: Simplify the @ask parsing using a singleton attribute. --- src/roster.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/roster.rs b/src/roster.rs index 1e049837..e8629727 100644 --- a/src/roster.rs +++ b/src/roster.rs @@ -38,10 +38,10 @@ generate_attribute!( generate_attribute!( /// The sub-state of subscription with a contact. - Ask, "ask", { - /// Pending sub-state of the 'none' subscription state - Subscribe => "subscribe", - } + Ask, "ask", ( + /// Pending sub-state of the 'none' subscription state. + Subscribe => "subscribe" + ) ); generate_element!( @@ -58,8 +58,8 @@ generate_element!( /// Subscription status of this contact. subscription: Subscription = "subscription" => default, - /// - ask: Option = "ask" => optional_empty + /// Indicates “Pending Out” sub-states for this contact. + ask: Ask = "ask" => default, ], children: [ @@ -174,7 +174,7 @@ mod tests { ); assert_eq!(roster.items[0].name, Some(String::from("Romeo"))); assert_eq!(roster.items[0].subscription, Subscription::Both); - assert_eq!(roster.items[0].ask, None); + assert_eq!(roster.items[0].ask, Ask::None); assert_eq!( roster.items[0].groups, vec!(Group::from_str("Friends").unwrap()) @@ -186,7 +186,7 @@ mod tests { ); assert_eq!(roster.items[3].name, Some(String::from("MyContact"))); assert_eq!(roster.items[3].subscription, Subscription::None); - assert_eq!(roster.items[3].ask, Some(Ask::Subscribe)); + assert_eq!(roster.items[3].ask, Ask::Subscribe); assert_eq!( roster.items[3].groups, vec!(Group::from_str("MyBuddies").unwrap())