From 476ebb92fbf9cd5e54b778cbe853be8d87bc0d10 Mon Sep 17 00:00:00 2001 From: tanishka <109246904+taniishkaaa@users.noreply.github.com> Date: Tue, 8 Oct 2024 23:36:17 +0530 Subject: [PATCH] clippy: Fix `type_complexity` warning in `components/script/dom` (#33727) * clippy: Fix type_complexity warning in components/script/dom Signed-off-by: taniishkaaa * Use destructure function only once Signed-off-by: taniishkaaa --------- Signed-off-by: taniishkaaa --- components/script/dom/range.rs | 36 ++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index d903862c136..ab7f9027d5e 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -52,6 +52,12 @@ pub struct Range { associated_selections: DomRefCell>>, } +pub struct ContainedChildren { + first_partially_contained_child: Option>, + last_partially_contained_child: Option>, + contained_children: Vec>, +} + impl Range { fn new_inherited( start_container: &Node, @@ -149,13 +155,7 @@ impl Range { } /// - fn contained_children( - &self, - ) -> Fallible<( - Option>, - Option>, - Vec>, - )> { + fn contained_children(&self) -> Fallible { let start_node = self.start_container(); let end_node = self.end_container(); // Steps 5-6. @@ -192,11 +192,11 @@ impl Range { return Err(Error::HierarchyRequest); } - Ok(( - first_contained_child, - last_contained_child, + Ok(ContainedChildren { + first_partially_contained_child: first_contained_child, + last_partially_contained_child: last_contained_child, contained_children, - )) + }) } /// @@ -583,8 +583,11 @@ impl RangeMethods for Range { } // Steps 5-12. - let (first_contained_child, last_contained_child, contained_children) = - self.contained_children()?; + let ContainedChildren { + first_partially_contained_child: first_contained_child, + last_partially_contained_child: last_contained_child, + contained_children, + } = self.contained_children()?; if let Some(child) = first_contained_child { // Step 13. @@ -697,8 +700,11 @@ impl RangeMethods for Range { } // Steps 5-12. - let (first_contained_child, last_contained_child, contained_children) = - self.contained_children()?; + let ContainedChildren { + first_partially_contained_child: first_contained_child, + last_partially_contained_child: last_contained_child, + contained_children, + } = self.contained_children()?; let (new_node, new_offset) = if start_node.is_inclusive_ancestor_of(&end_node) { // Step 13.