clippy: Fix type_complexity warning in components/script/dom (#33727)

* clippy: Fix type_complexity warning in components/script/dom

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

* Use destructure function only once

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>

---------

Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
This commit is contained in:
tanishka 2024-10-08 23:36:17 +05:30 committed by GitHub
parent 5079552f93
commit 476ebb92fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -52,6 +52,12 @@ pub struct Range {
associated_selections: DomRefCell<Vec<Dom<Selection>>>,
}
pub struct ContainedChildren {
first_partially_contained_child: Option<DomRoot<Node>>,
last_partially_contained_child: Option<DomRoot<Node>>,
contained_children: Vec<DomRoot<Node>>,
}
impl Range {
fn new_inherited(
start_container: &Node,
@ -149,13 +155,7 @@ impl Range {
}
/// <https://dom.spec.whatwg.org/#concept-range-clone>
fn contained_children(
&self,
) -> Fallible<(
Option<DomRoot<Node>>,
Option<DomRoot<Node>>,
Vec<DomRoot<Node>>,
)> {
fn contained_children(&self) -> Fallible<ContainedChildren> {
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,
))
})
}
/// <https://dom.spec.whatwg.org/#concept-range-bp-set>
@ -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.