attr: impl Debug for Attributes manually
show key value pairs instead of internal structure
This commit is contained in:
parent
122cb84d2d
commit
f31398a796
1 changed files with 16 additions and 1 deletions
17
src/attr.rs
17
src/attr.rs
|
@ -98,7 +98,7 @@ impl<'s> Iterator for AttributeValueParts<'s> {
|
|||
// Attributes are relatively rare, we choose to pay 8 bytes always and sometimes an extra
|
||||
// indirection instead of always 24 bytes.
|
||||
#[allow(clippy::box_vec)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||
#[derive(Clone, PartialEq, Eq, Default)]
|
||||
pub struct Attributes<'s>(Option<Box<Vec<(&'s str, AttributeValue<'s>)>>>);
|
||||
|
||||
impl<'s> Attributes<'s> {
|
||||
|
@ -202,6 +202,21 @@ impl<'s> FromIterator<(&'s str, &'s str)> for Attributes<'s> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'s> std::fmt::Debug for Attributes<'s> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{{")?;
|
||||
let mut first = true;
|
||||
for (k, v) in self.iter() {
|
||||
if !first {
|
||||
write!(f, ", ")?;
|
||||
}
|
||||
first = false;
|
||||
write!(f, "{}=\"{}\"", k, v.raw)?;
|
||||
}
|
||||
write!(f, "}}")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
enum State {
|
||||
Start,
|
||||
|
|
Loading…
Reference in a new issue