fmt: apply cargofmt with new rules for lit structs

This commit is contained in:
Jonathan Kelley committed 2022-01-31 02:40:12 -05:00
1 parent 11f6b93889
commit 5bffbba682
11 files changed
+54 -195

No files matched your search

+1 -3
View File
@@ -12,9 +12,7 @@ pub(crate) struct BubbleState {
impl BubbleState {
pub fn new() -> Self {
Self {
canceled: Cell::new(false),
}
Self { canceled: Cell::new(false) }
}
}
+5 -22
View File
@@ -55,9 +55,7 @@ impl<'a, 'b> LazyNodes<'a, 'b> {
fac.map(inner)
};
Self {
inner: StackNodeStorage::Heap(Box::new(val)),
}
Self { inner: StackNodeStorage::Heap(Box::new(val)) }
}
pub fn new(_val: impl FnOnce(NodeFactory<'a>) -> VNode<'a> + 'b) -> Self {
@@ -71,9 +69,7 @@ impl<'a, 'b> LazyNodes<'a, 'b> {
// miri does not know how to work with mucking directly into bytes
if cfg!(miri) {
Self {
inner: StackNodeStorage::Heap(Box::new(val)),
}
Self { inner: StackNodeStorage::Heap(Box::new(val)) }
} else {
unsafe { LazyNodes::new_inner(val) }
}
@@ -117,9 +113,7 @@ impl<'a, 'b> LazyNodes<'a, 'b> {
let max_size = mem::size_of::<StackHeapSize>();
if stored_size > max_size {
Self {
inner: StackNodeStorage::Heap(Box::new(val)),
}
Self { inner: StackNodeStorage::Heap(Box::new(val)) }
} else {
let mut buf: StackHeapSize = StackHeapSize::default();
@@ -143,13 +137,7 @@ impl<'a, 'b> LazyNodes<'a, 'b> {
std::mem::forget(val);
Self {
inner: StackNodeStorage::Stack(LazyStack {
_align: [],
buf,
dropped: false,
}),
}
Self { inner: StackNodeStorage::Stack(LazyStack { _align: [], buf, dropped: false }) }
}
}
@@ -298,12 +286,7 @@ mod tests {
}
let inner = Rc::new(0);
let mut dom = VirtualDom::new_with_props(
app,
AppProps {
inner: inner.clone(),
},
);
let mut dom = VirtualDom::new_with_props(app, AppProps { inner: inner.clone() });
dom.rebuild();
drop(dom);
+7 -27
View File
@@ -115,11 +115,7 @@ use DomEdit::*;
impl<'a> Mutations<'a> {
pub(crate) fn new() -> Self {
Self {
edits: Vec::new(),
refs: Vec::new(),
diffed_scopes: Default::default(),
}
Self { edits: Vec::new(), refs: Vec::new(), diffed_scopes: Default::default() }
}
// Navigation
@@ -178,19 +174,12 @@ impl<'a> Mutations<'a> {
// events
pub(crate) fn new_event_listener(&mut self, listener: &Listener, scope: ScopeId) {
let Listener {
event,
mounted_node,
..
} = listener;
let Listener { event, mounted_node, .. } = listener;
let element_id = mounted_node.get().unwrap().as_u64();
self.edits.push(NewEventListener {
scope,
event_name: event,
root: element_id,
});
self.edits
.push(NewEventListener { scope, event_name: event, root: element_id });
}
pub(crate) fn remove_event_listener(&mut self, event: &'static str, root: u64) {
self.edits.push(RemoveEventListener { event, root });
@@ -202,19 +191,10 @@ impl<'a> Mutations<'a> {
}
pub(crate) fn set_attribute(&mut self, attribute: &'a Attribute, root: u64) {
let Attribute {
name,
value,
namespace,
..
} = attribute;
let Attribute { name, value, namespace, .. } = attribute;
self.edits.push(SetAttribute {
field: name,
value,
ns: *namespace,
root,
});
self.edits
.push(SetAttribute { field: name, value, ns: *namespace, root });
}
pub(crate) fn remove_attribute(&mut self, attribute: &Attribute, root: u64) {
+3 -3
View File
@@ -4,7 +4,7 @@
//! cheap and *very* fast to construct - building a full tree should be quick.
use crate::{
innerlude::{Element, FcSlot, Properties, Scope, ScopeId, ScopeState},
innerlude::{ComponentPtr, Element, Properties, Scope, ScopeId, ScopeState},
lazynodes::LazyNodes,
AnyEvent, Component,
};
@@ -390,7 +390,7 @@ pub struct VComponent<'src> {
pub originator: ScopeId,
pub scope: Cell<Option<ScopeId>>,
pub can_memoize: bool,
pub user_fc: FcSlot,
pub user_fc: ComponentPtr,
pub fn_name: &'static str,
pub props: RefCell<Option<Box<dyn AnyProps + 'src>>>,
}
@@ -551,7 +551,7 @@ impl<'a> NodeFactory<'a> {
key: key.map(|f| self.raw_text(f).0),
scope: Default::default(),
can_memoize: P::IS_STATIC,
user_fc: component as *mut std::os::raw::c_void,
user_fc: component as ComponentPtr,
originator: self.scope.scope_id(),
fn_name,
props: RefCell::new(Some(Box::new(VComponentProps {
+5 -5
View File
@@ -14,8 +14,8 @@ use std::{
};
/// for traceability, we use the raw fn pointer to identify the function
/// we can use this with the traceback crate to resolve funciton names
pub(crate) type FcSlot = *mut std::os::raw::c_void;
/// we also get the component name, but that's not necessarily unique in the app
pub(crate) type ComponentPtr = *mut std::os::raw::c_void;
pub(crate) struct Heuristic {
hook_arena_size: usize,
@@ -30,7 +30,7 @@ pub(crate) struct ScopeArena {
pub scope_gen: Cell<usize>,
pub bump: Bump,
pub scopes: RefCell<FxHashMap<ScopeId, *mut ScopeState>>,
pub heuristics: RefCell<FxHashMap<FcSlot, Heuristic>>,
pub heuristics: RefCell<FxHashMap<ComponentPtr, Heuristic>>,
pub free_scopes: RefCell<Vec<*mut ScopeState>>,
pub nodes: RefCell<Slab<*const VNode<'static>>>,
pub tasks: Rc<TaskQueue>,
@@ -84,7 +84,7 @@ impl ScopeArena {
pub(crate) fn new_with_key(
&self,
fc_ptr: FcSlot,
fc_ptr: ComponentPtr,
vcomp: Box<dyn AnyProps>,
parent_scope: Option<ScopeId>,
container: ElementId,
@@ -469,7 +469,7 @@ pub struct ScopeState {
pub(crate) container: ElementId,
pub(crate) our_arena_idx: ScopeId,
pub(crate) height: u32,
pub(crate) fnptr: FcSlot,
pub(crate) fnptr: ComponentPtr,
// todo: subtrees
pub(crate) is_subtree_root: Cell<bool>,
+1 -4
View File
@@ -10,10 +10,7 @@ pub struct ElementIdIterator<'a> {
impl<'a> ElementIdIterator<'a> {
pub fn new(vdom: &'a VirtualDom, node: &'a VNode<'a>) -> Self {
Self {
vdom,
stack: smallvec::smallvec![(0, node)],
}
Self { vdom, stack: smallvec::smallvec![(0, node)] }
}
}