Skip to content

Commit

Permalink
Merge pull request #190 from gfaster/master
Browse files Browse the repository at this point in the history
Make ElementRef Debug impl use Element
  • Loading branch information
cfvescovo authored Jul 31, 2024
2 parents 27dd786 + f5cc684 commit 9242d09
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/element_ref/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Element references.
use std::fmt;
use std::fmt::{self, Debug};
use std::ops::Deref;

use ego_tree::iter::{Edge, Traverse};
Expand All @@ -15,7 +15,7 @@ use crate::{Node, Selector};
///
/// This wrapper implements the `Element` trait from the `selectors` crate, which allows it to be
/// matched against CSS selectors.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub struct ElementRef<'a> {
node: NodeRef<'a, Node>,
}
Expand Down Expand Up @@ -116,6 +116,12 @@ impl<'a> ElementRef<'a> {
}
}

impl<'a> Debug for ElementRef<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Debug::fmt(self.value(), f)
}
}

impl<'a> Deref for ElementRef<'a> {
type Target = NodeRef<'a, Node>;
fn deref(&self) -> &NodeRef<'a, Node> {
Expand All @@ -131,7 +137,7 @@ pub struct Select<'a, 'b> {
nth_index_cache: NthIndexCache,
}

impl fmt::Debug for Select<'_, '_> {
impl Debug for Select<'_, '_> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.debug_struct("Select")
.field("scope", &self.scope)
Expand Down

0 comments on commit 9242d09

Please sign in to comment.