document all the things!

This commit is contained in:
lumi 2017-02-21 15:46:06 +01:00
commit 0a45a6993e
4 changed files with 334 additions and 5 deletions

View file

@ -2,9 +2,16 @@ use xml::escape::escape_str_attribute;
use std::fmt;
/// An attribute of a DOM element.
///
/// This is of the form: `name`="`value`"
///
/// This does not support prefixed/namespaced attributes yet.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Attribute {
/// The name of the attribute.
pub name: String,
/// The value of the attribute.
pub value: String,
}
@ -15,6 +22,18 @@ impl fmt::Display for Attribute {
}
impl Attribute {
/// Construct a new attribute from the given `name` and `value`.
///
/// # Examples
///
/// ```
/// use minidom::Attribute;
///
/// let attr = Attribute::new("name", "value");
///
/// assert_eq!(attr.name, "name");
/// assert_eq!(attr.value, "value");
/// ```
pub fn new<N: Into<String>, V: Into<String>>(name: N, value: V) -> Attribute {
Attribute {
name: name.into(),