//! Contains XML attributes manipulation types and functions. //!
use std::fmt;
use name::{Name, OwnedName}; use escape::escape_str_attribute;
/// A borrowed version of an XML attribute. /// /// Consists of a borrowed qualified name and a borrowed string value. #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pubstruct Attribute<'a> { /// Attribute name. pub name: Name<'a>,
impl<'a> Attribute<'a> { /// Creates an owned attribute out of this borrowed one. #[inline] pubfn to_owned(&self) -> OwnedAttribute {
OwnedAttribute {
name: self.name.into(),
value: self.value.into(),
}
}
/// Creates a borrowed attribute using the provided borrowed name and a borrowed string value. #[inline] pubfn new(name: Name<'a>, value: &'a str) -> Attribute<'a> {
Attribute { name, value, }
}
}
/// An owned version of an XML attribute. /// /// Consists of an owned qualified name and an owned string value. #[derive(Clone, Eq, PartialEq, Hash, Debug)] pubstruct OwnedAttribute { /// Attribute name. pub name: OwnedName,
/// Attribute value. pub value: String
}
impl OwnedAttribute { /// Returns a borrowed `Attribute` out of this owned one. pubfn borrow(&self) -> Attribute {
Attribute {
name: self.name.borrow(),
value: &*self.value,
}
}
/// Creates a new owned attribute using the provided owned name and an owned string value. #[inline] pubfn new<S: Into<String>>(name: OwnedName, value: S) -> OwnedAttribute {
OwnedAttribute {
name,
value: value.into(),
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.