clippy fix

This commit is contained in:
Evan Almloff committed 2024-01-09 10:09:58 -06:00
1 parent aed29b1dec
commit eb602fc29f
5 files changed
+32 -59

No files matched your search

+6 -15
View File
@@ -1,23 +1,14 @@
use std::{
cell::RefMut,
ops::{Deref, DerefMut},
};
use std::ops::Deref;
use crate::{
any_props::AnyProps,
arena::ElementId,
innerlude::{
DirtyScope, ElementPath, ElementRef, VComponent, VNodeMount, VText, WriteMutations,
},
innerlude::{DirtyScope, ElementRef, VComponent, VNodeMount, WriteMutations},
nodes::RenderReturn,
nodes::{DynamicNode, VNode},
nodes::VNode,
scopes::ScopeId,
virtual_dom::VirtualDom,
TemplateNode,
};
use DynamicNode::*;
impl VirtualDom {
pub(crate) fn diff_scope(
&mut self,
@@ -127,8 +118,8 @@ impl VNode {
pub(super) fn create_component_node(
&self,
mount: &mut VNodeMount,
idx: usize,
_mount: &mut VNodeMount,
_idx: usize,
component: &VComponent,
parent: Option<ElementRef>,
dom: &mut VirtualDom,
@@ -140,7 +131,7 @@ impl VNode {
.context()
.id;
let mut new = dom.run_scope(scope);
let new = dom.run_scope(scope);
dom.scopes[scope.0].last_rendered_node = Some(new.clone());
+10 -13
View File
@@ -55,12 +55,9 @@ impl VirtualDom {
match old.len().cmp(&new.len()) {
Ordering::Greater => self.remove_nodes(to, &old[new.len()..]),
Ordering::Less => self.create_and_insert_after(
to,
&new[old.len()..],
&mut old.last().unwrap(),
parent,
),
Ordering::Less => {
self.create_and_insert_after(to, &new[old.len()..], old.last().unwrap(), parent)
}
Ordering::Equal => {}
}
@@ -144,16 +141,16 @@ impl VirtualDom {
// we need to find the right "foothold" though - we shouldn't use the "append" at all
if left_offset == 0 {
// insert at the beginning of the old list
let mut foothold = &old[old.len() - right_offset];
self.create_and_insert_before(to, new_middle, &mut foothold, parent);
let foothold = &old[old.len() - right_offset];
self.create_and_insert_before(to, new_middle, foothold, parent);
} else if right_offset == 0 {
// insert at the end the old list
let mut foothold = old.last().unwrap();
self.create_and_insert_after(to, new_middle, &mut foothold, parent);
let foothold = old.last().unwrap();
self.create_and_insert_after(to, new_middle, foothold, parent);
} else {
// inserting in the middle
let mut foothold = &old[left_offset - 1];
self.create_and_insert_after(to, new_middle, &mut foothold, parent);
let foothold = &old[left_offset - 1];
self.create_and_insert_after(to, new_middle, foothold, parent);
}
} else {
self.diff_keyed_middle(to, old_middle, new_middle, parent);
@@ -186,7 +183,7 @@ impl VirtualDom {
// If that was all of the old children, then create and append the remaining
// new children and we're finished.
if left_offset == old.len() {
self.create_and_insert_after(to, &new[left_offset..], &mut old.last().unwrap(), parent);
self.create_and_insert_after(to, &new[left_offset..], old.last().unwrap(), parent);
return None;
}
+3 -14
View File
@@ -1,23 +1,12 @@
use std::{
cell::RefMut,
ops::{Deref, DerefMut},
};
use crate::{
any_props::AnyProps,
arena::ElementId,
innerlude::{
DirtyScope, ElementPath, ElementRef, VComponent, VNodeMount, VText, WriteMutations,
},
nodes::RenderReturn,
nodes::{DynamicNode, VNode},
innerlude::{ElementRef, VNodeMount, WriteMutations},
nodes::VNode,
scopes::ScopeId,
virtual_dom::VirtualDom,
Template, TemplateNode,
};
use DynamicNode::*;
mod component;
mod iterator;
mod node;
@@ -105,7 +94,7 @@ impl VirtualDom {
gen_muts: bool,
) {
// Remove the component from the dom
if let Some(mut node) = self.scopes[scope.0].last_rendered_node.take() {
if let Some(node) = self.scopes[scope.0].last_rendered_node.take() {
node.remove_node(self, to, gen_muts)
};
+12 -16
View File
@@ -1,16 +1,12 @@
use crate::{Attribute, AttributeValue, DynamicNode::*, VPlaceholder};
use crate::{Attribute, AttributeValue, DynamicNode::*};
use crate::{VNode, VirtualDom, WriteMutations};
use core::iter::Peekable;
use std::cell::Ref;
use std::{
cell::RefMut,
ops::{Deref, DerefMut},
};
use std::cell::RefMut;
use crate::{
any_props::AnyProps,
arena::ElementId,
innerlude::{DirtyScope, ElementPath, ElementRef, VComponent, VNodeMount, VText},
innerlude::{ElementPath, ElementRef, VComponent, VNodeMount, VText},
nodes::DynamicNode,
nodes::RenderReturn,
scopes::ScopeId,
@@ -168,7 +164,7 @@ impl VNode {
let child = children.first().unwrap();
child.find_first_element(dom)
}
Component(comp) => {
Component(_comp) => {
let scope = ScopeId(mount.mounted_dynamic_nodes[*id]);
match dom.get_scope(scope).unwrap().root_node() {
RenderReturn::Ready(child) => child.find_first_element(dom),
@@ -190,7 +186,7 @@ impl VNode {
match &self.dynamic_nodes[*id] {
Placeholder(_) | Text(_) => ElementId(mount.mounted_dynamic_nodes[*id]),
Fragment(t) => t.last().unwrap().find_last_element(dom),
Component(comp) => {
Component(_comp) => {
let scope = ScopeId(mount.mounted_dynamic_nodes[*id]);
match dom.get_scope(scope).unwrap().root_node() {
RenderReturn::Ready(node) => node.find_last_element(dom),
@@ -304,7 +300,7 @@ impl VNode {
gen_muts: bool,
) {
match node {
Component(comp) => {
Component(_comp) => {
let scope_id = ScopeId(mount.mounted_dynamic_nodes[idx]);
dom.remove_component_node(to, scope_id, gen_muts);
}
@@ -314,7 +310,7 @@ impl VNode {
}
Fragment(nodes) => nodes
.iter()
.for_each(|node| self.remove_node(dom, to, gen_muts)),
.for_each(|_node| self.remove_node(dom, to, gen_muts)),
};
}
@@ -341,12 +337,12 @@ impl VNode {
&self,
mount: &VNodeMount,
dom: &mut VirtualDom,
to: &mut impl WriteMutations,
_to: &mut impl WriteMutations,
) {
let mut id = None;
let id = None;
for (idx, path) in self.template.get().attr_paths.iter().enumerate() {
let attr = &self.dynamic_attrs[idx];
let _attr = &self.dynamic_attrs[idx];
// We clean up the roots in the next step, so don't worry about them here
if path.len() <= 1 {
@@ -426,7 +422,7 @@ impl VNode {
for (idx, (old_component, new_component)) in components.into_iter().enumerate() {
let scope_id = ScopeId(self.assert_mounted().mounted_dynamic_nodes[idx]);
self.diff_vcomponent(
&mut *mount,
&mut mount,
idx,
old_component,
new_component,
@@ -736,7 +732,7 @@ impl VNode {
to.create_event_listener(&attribute.name[2..], id);
}
_ => {
to.set_attribute(&attribute.name, attribute.namespace, &attribute.value, id);
to.set_attribute(attribute.name, attribute.namespace, &attribute.value, id);
}
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
use crate::any_props::{BoxedAnyProps, VProps};
use crate::innerlude::{ElementRef, EventHandler};
use crate::Properties;
use crate::{arena::ElementId, Element, Event, ScopeId};
use crate::{arena::ElementId, Element, Event};
use std::cell::RefCell;
use std::ops::Deref;
use std::rc::Rc;