disco: Add a helper constructor for Feature.

Emmanuel Gil Peyrot created

Change summary

src/disco.rs | 9 +++++++++
1 file changed, 9 insertions(+)

Detailed changes

src/disco.rs 🔗

@@ -34,6 +34,15 @@ attributes: [
     var: String = "var" => required,
 ]);
 
+impl Feature {
+    /// Create a new `<feature/>` with the according `@var`.
+    pub fn new(var: &str) -> Feature {
+        Feature {
+            var: String::from(var)
+        }
+    }
+}
+
 /// Structure representing an `<identity xmlns='http://jabber.org/protocol/disco#info'/>` element.
 #[derive(Debug, Clone)]
 pub struct Identity {