pub struct Attribute<'html> {
pub key: &'html str,
pub value: Option<&'html str>,
}Expand description
A key-value pair representing an HTML element attribute.
Both key and value are zero-copy &str references into the
original HTML source.
§Example
use scah::{Query, Save, parse};
let html = r#"<a href="https://example.com" target="_blank">Link</a>"#;
let queries = &[Query::all("a", Save::all()).build()];
let store = parse(html, queries);
let a = store.get("a").unwrap().next().unwrap();
let attrs = a.attributes(&store).unwrap();
assert_eq!(attrs[0].key, "href");
assert_eq!(attrs[0].value, Some("https://example.com"));
assert_eq!(attrs[1].key, "target");
assert_eq!(attrs[1].value, Some("_blank"));Fields§
§key: &'html strThe attribute name (e.g. "href", "class", "data-id").
value: Option<&'html str>The attribute value, or None for boolean attributes (e.g. disabled).
Trait Implementations§
impl<'html> StructuralPartialEq for Attribute<'html>
Auto Trait Implementations§
impl<'html> Freeze for Attribute<'html>
impl<'html> RefUnwindSafe for Attribute<'html>
impl<'html> Send for Attribute<'html>
impl<'html> Sync for Attribute<'html>
impl<'html> Unpin for Attribute<'html>
impl<'html> UnsafeUnpin for Attribute<'html>
impl<'html> UnwindSafe for Attribute<'html>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more