Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ElementRef Debug impl use Element #190

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading