diff --git a/src/element.rs b/src/element.rs index 65cf125..00adbfd 100644 --- a/src/element.rs +++ b/src/element.rs @@ -143,18 +143,7 @@ struct ScanNodes<'a, T: Debug> { } impl<'a> ScanNodes<'a, NonStrictComparison> { - fn new(nodes: Vec) -> ScanNodes<'a, NonStrictComparison> { - Self { - nodes, - context: None, - _strict: PhantomData, - } - } - - fn new_with_context( - nodes: Vec, - context: Option<&'a Context>, - ) -> ScanNodes<'a, NonStrictComparison> { + fn new(nodes: Vec, context: Option<&'a Context>) -> ScanNodes<'a, NonStrictComparison> { Self { nodes, context, @@ -164,15 +153,7 @@ impl<'a> ScanNodes<'a, NonStrictComparison> { } impl<'a> ScanNodes<'a, StrictComparison> { - fn new_strict(nodes: Vec) -> ScanNodes<'a, StrictComparison> { - Self { - nodes, - context: None, - _strict: PhantomData, - } - } - - fn new_strict_with_context( + fn new_strict( nodes: Vec, context: Option<&'a Context>, ) -> ScanNodes<'a, StrictComparison> { @@ -317,14 +298,11 @@ impl<'a, 'b> PartialEq<&Element> for ScanElement<'a, 'b> { _ => (), } - let nodes = ScanNodes::new_strict_with_context( - self.elem.nodes().cloned().collect(), - self.context, - ); + let nodes = + ScanNodes::new_strict(self.elem.nodes().cloned().collect(), self.context); nodes == onodes } else { - let nodes = - ScanNodes::new_with_context(self.elem.nodes().cloned().collect(), self.context); + let nodes = ScanNodes::new(self.elem.nodes().cloned().collect(), self.context); nodes == onodes } } else { @@ -347,12 +325,12 @@ mod tests { let elem1 = Node::Element(Element::from_str("").unwrap()); assert_eq!( - ScanNodes::new_strict(vec![elem1.clone()]), + ScanNodes::new_strict(vec![elem1.clone()], None), vec![elem1.clone()], ); assert_ne!( - ScanNodes::new_strict(vec![text1.clone()]), + ScanNodes::new_strict(vec![text1.clone()], None), vec![text2.clone()], ); } @@ -364,32 +342,32 @@ mod tests { let elem1 = Node::Element(Element::from_str("").unwrap()); assert_eq!( - ScanNodes::new_strict(vec![elem1.clone()]), + ScanNodes::new_strict(vec![elem1.clone()], None), vec![elem1.clone()], ); assert_eq!( - ScanNodes::new_strict(vec![text1.clone(), elem1.clone(), text2.clone()]), + ScanNodes::new_strict(vec![text1.clone(), elem1.clone(), text2.clone()], None), vec![elem1.clone()], ); assert_eq!( - ScanNodes::new_strict(vec![text1.clone(), elem1.clone()]), + ScanNodes::new_strict(vec![text1.clone(), elem1.clone()], None), vec![elem1.clone(), text2.clone()], ); assert_eq!( - ScanNodes::new_strict(vec![elem1.clone(), text1.clone(), elem1.clone()]), + ScanNodes::new_strict(vec![elem1.clone(), text1.clone(), elem1.clone()], None), vec![elem1.clone(), elem1.clone()], ); assert_ne!( - ScanNodes::new_strict(vec![elem1.clone(), text1.clone(), elem1.clone()]), + ScanNodes::new_strict(vec![elem1.clone(), text1.clone(), elem1.clone()], None), vec![elem1.clone()], ); assert_ne!( - ScanNodes::new_strict(vec![Node::Text(String::from("\n\tfoo\n"))]), + ScanNodes::new_strict(vec![Node::Text(String::from("\n\tfoo\n"))], None), vec![Node::Text(String::from("\n\tfoo"))], ); }