FIx: cargo fix to clean up things

This commit is contained in:
Jonathan Kelley committed 2021-03-10 19:42:31 -05:00
1 parent 29751a4bab
commit 78d093a945
23 files changed
+91 -101

No files matched your search

+4 -4
View File
@@ -7,7 +7,7 @@
fn main() {}
use std::fmt::Debug;
use dioxus_core::prelude::*;
@@ -22,7 +22,7 @@ struct ListItem {
}
fn app(ctx: Context, props: &Props) -> DomTree {
let (f, setter) = use_state(&ctx, || 0);
let (_f, setter) = use_state(&ctx, || 0);
ctx.render(move |c| {
let mut root = builder::ElementBuilder::new(c, "div");
@@ -64,7 +64,7 @@ struct ChildProps<'a> {
}
impl PartialEq for ChildProps<'_> {
fn eq(&self, other: &Self) -> bool {
fn eq(&self, _other: &Self) -> bool {
// assume the dyn fn is never stable -
// wrap with use_callback if it's an issue for you
false
@@ -78,7 +78,7 @@ impl<'a> Properties for ChildProps<'a> {
}
}
fn ChildItem(ctx: Context, props: &ChildProps) -> DomTree {
fn ChildItem(_ctx: Context, _props: &ChildProps) -> DomTree {
todo!()
// ctx.render(rsx! {
// div {
+4 -4
View File
@@ -1,10 +1,10 @@
use dioxus_core::component::fc_to_builder;
use dioxus_core::prelude::*;
use dioxus_core_macro::fc;
use std::marker::PhantomData;
static BLAH: FC<()> = |ctx, props| {
static BLAH: FC<()> = |ctx, _props| {
let g = "asd".to_string();
ctx.render(rsx! {
div {
@@ -20,7 +20,7 @@ pub struct ExampleProps {
some_field: String,
}
static SomeComponent: FC<ExampleProps> = |ctx, props| {
static SomeComponent: FC<ExampleProps> = |ctx, _props| {
ctx.render(rsx! {
div { }
})
+4 -4
View File
@@ -1,16 +1,16 @@
// #[macro_use]
extern crate fstrings;
use bumpalo::collections::String;
// use dioxus_core::ifmt;
// use fstrings::format_args_f;
use bumpalo::core_alloc::fmt::Write;
fn main() {
let bump = bumpalo::Bump::new();
let b = &bump;
let world = "123";
let _b = &bump;
let _world = "123";
// dioxus_core::ifmt!(in b; "Hello {world}";);
}
+1 -1
View File
@@ -14,7 +14,7 @@ struct SomeProps {
fn main() {
let g: SomeProps = SomeProps::builder().a(10).b(10).build();
let r = g.b.unwrap_or_else(|| 10);
let _r = g.b.unwrap_or_else(|| 10);
}
fn auto_into_some() {}
+4 -4
View File
@@ -1,4 +1,4 @@
use bumpalo::Bump;
use dioxus_core::prelude::*;
fn main() {}
@@ -26,8 +26,8 @@ struct Button<'a> {
}
impl Render for Button<'_> {
fn render(ctx: Context, props: &Self) -> DomTree {
let onfocus = move |evt: ()| log::debug!("Focused");
fn render(ctx: Context, _props: &Self) -> DomTree {
let _onfocus = move |_evt: ()| log::debug!("Focused");
// todo!()
ctx.render(rsx! {
@@ -35,7 +35,7 @@ impl Render for Button<'_> {
// ..props.attrs,
class: "abc123",
// style: { a: 2, b: 3, c: 4 },
onclick: move |evt| {
onclick: move |_evt| {
// log::info("hello world");
},
// Custom1 { a: 123 }
+1 -1
View File
@@ -3,7 +3,7 @@ use dioxus_core::{component::Properties, prelude::*};
fn main() -> Result<(), ()> {
let p1 = SomeProps { name: "bob".into() };
let mut vdom = VirtualDom::new_with_props(Example, p1);
let _vdom = VirtualDom::new_with_props(Example, p1);
Ok(())
}
+1 -1
View File
@@ -29,6 +29,6 @@ impl Properties for () {
}
}
pub fn fc_to_builder<T: Properties>(f: FC<T>) -> T::Builder {
pub fn fc_to_builder<T: Properties>(_f: FC<T>) -> T::Builder {
T::builder()
}
+6 -7
View File
@@ -34,11 +34,10 @@
//! - https://hacks.mozilla.org/2019/03/fast-bump-allocated-virtual-doms-with-rust-and-wasm/
use crate::{
innerlude::*,
scope::{create_scoped, Scoped},
};
use bumpalo::Bump;
use fxhash::{FxHashMap, FxHashSet};
use generational_arena::Arena;
use std::{cell::RefCell, cmp::Ordering, collections::VecDeque, rc::Rc};
/// The DiffState is a cursor internal to the VirtualDOM's diffing algorithm that allows persistence of state while
@@ -112,7 +111,7 @@ impl<'a> DiffMachine<'a> {
self.diff_children(eold.children, enew.children);
}
(VNode::Component(cold), VNode::Component(cnew)) => {
(VNode::Component(_cold), VNode::Component(_cnew)) => {
// if cold.comp != cnew.comp {
// // queue an event to mount this new component
// return;
@@ -123,7 +122,7 @@ impl<'a> DiffMachine<'a> {
todo!("Usage of component VNode not currently supported");
}
(_, VNode::Component(new)) => {
(_, VNode::Component(_new)) => {
// we have no stable reference to work from
// push the lifecycle event onto the queue
// self.lifecycle_events
@@ -142,7 +141,7 @@ impl<'a> DiffMachine<'a> {
// push the current
}
(VNode::Component(old), _) => {
(VNode::Component(_old), _) => {
todo!("Usage of component VNode not currently supported");
}
@@ -165,7 +164,7 @@ impl<'a> DiffMachine<'a> {
self.change_list.commit_traversal();
}
'outer1: for (l_idx, new_l) in new.iter().enumerate() {
'outer1: for (_l_idx, new_l) in new.iter().enumerate() {
// unsafe {
// Safety relies on removing `new_l` from the registry manually at
// the end of its lifetime. This happens below in the `'outer2`
@@ -818,7 +817,7 @@ impl<'a> DiffMachine<'a> {
self.change_list.create_element(tag_name);
}
listeners.iter().enumerate().for_each(|(id, listener)| {
listeners.iter().enumerate().for_each(|(_id, listener)| {
self.change_list
.new_event_listener(listener.event, listener.scope, listener.id)
});
+5 -5
View File
@@ -137,7 +137,7 @@ mod use_reducer_def {
pub fn use_reducer<'a, 'c, State: 'static, Action: 'static>(
ctx: &'c Context<'a>,
initial_state_fn: impl FnOnce() -> State,
reducer: impl Fn(&mut State, Action),
_reducer: impl Fn(&mut State, Action),
) -> (&'a State, &'a impl Fn(Action)) {
ctx.use_hook(
move || UseReducer {
@@ -146,7 +146,7 @@ mod use_reducer_def {
caller: Box::new(|_| println!("setter called!")),
},
move |hook| {
let inner = hook.new_val.clone();
let _inner = hook.new_val.clone();
let scheduled_update = ctx.schedule_update();
// get ownership of the new val and replace the current with the new
@@ -157,7 +157,7 @@ mod use_reducer_def {
}
// todo: swap out the caller with a subscription call and an internal update
hook.caller = Box::new(move |new_val| {
hook.caller = Box::new(move |_new_val| {
// update the setter with the new value
// let mut new_inner = inner.as_ref().borrow_mut();
// *new_inner = Some(new_val);
@@ -175,9 +175,9 @@ mod use_reducer_def {
// #[cfg(test)]
mod tests {
use super::*;
use crate::prelude::*;
use bumpalo::Bump;
enum Actions {
Incr,
Decr,
+3 -3
View File
@@ -91,11 +91,11 @@ pub(crate) mod innerlude {
// pub(crate) use crate::component::Properties;
pub(crate) use crate::component::Properties;
pub(crate) use crate::context::Context;
pub(crate) use crate::error::{Error, Result};
pub(crate) use crate::error::{Result};
pub use crate::events::EventTrigger;
use crate::nodes;
pub(crate) use crate::scope::Scope;
pub(crate) use crate::virtual_dom::VirtualDom;
pub(crate) use nodes::*;
pub use crate::component::ScopeIdx;
+7 -7
View File
@@ -1,6 +1,6 @@
//! Helpers for building virtual DOM VNodes.
use std::{borrow::BorrowMut, ops::Deref};
use std::{borrow::BorrowMut};
use crate::{
context::NodeCtx,
@@ -10,8 +10,8 @@ use crate::{
prelude::VElement,
};
use bumpalo::format;
use bumpalo::Bump;
/// A virtual DOM element builder.
///
@@ -339,7 +339,7 @@ where
/// })
/// .finish();
/// ```
pub fn on(mut self, event: &'static str, callback: impl Fn(VirtualEvent) + 'a) -> Self {
pub fn on(self, event: &'static str, callback: impl Fn(VirtualEvent) + 'a) -> Self {
let listener = Listener {
event,
callback: self.ctx.bump.alloc(callback),
@@ -527,9 +527,9 @@ pub fn attr<'a>(name: &'static str, value: &'a str) -> Attribute<'a> {
// _f: crate::innerlude::FC<T>,
// _props: T
pub fn virtual_child<'a, 'b, T: crate::innerlude::Properties>(
ctx: &'b NodeCtx<'a>,
f: FC<T>,
p: T,
_ctx: &'b NodeCtx<'a>,
_f: FC<T>,
_p: T,
) -> VNode<'a> {
// crate::nodes::VComponent
todo!()
+3 -3
View File
@@ -11,7 +11,7 @@ use crate::{
use bumpalo::Bump;
use std::fmt::Debug;
use std::{
any::{Any, TypeId},
any::{Any},
cell::RefCell,
marker::PhantomData,
rc::Rc,
@@ -280,14 +280,14 @@ pub struct VComponent<'src> {
}
pub struct Comparator(Box<dyn Fn(&dyn Any) -> bool>);
impl std::fmt::Debug for Comparator {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Ok(())
}
}
pub struct Caller(Box<dyn Fn(Context) -> DomTree>);
impl std::fmt::Debug for Caller {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Ok(())
}
}
+2 -2
View File
@@ -5,7 +5,7 @@ use crate::nodes::VNode;
use bumpalo::Bump;
use std::{
any::{Any, TypeId},
any::{Any},
cell::RefCell,
marker::PhantomData,
ops::Deref,
@@ -145,7 +145,7 @@ impl<P: Properties + 'static> Scoped for Scope<P> {
.expect("Viewing did not happen");
}
fn compare_props(&self, new: &Any) -> bool {
fn compare_props(&self, new: &dyn Any) -> bool {
new.downcast_ref::<P>()
.map(|f| &self.props == f)
.expect("Props should not be of a different type")
+4 -13
View File
@@ -7,16 +7,7 @@ use crate::{
};
use bumpalo::Bump;
use generational_arena::Arena;
use std::{
any::TypeId,
borrow::BorrowMut,
cell::{RefCell, UnsafeCell},
collections::{vec_deque, VecDeque},
future::Future,
marker::PhantomData,
rc::Rc,
sync::atomic::AtomicUsize,
};
/// An integrated virtual node system that progresses events and diffs UI trees.
/// Differences are converted into patches which a renderer can use to draw the UI.
@@ -68,7 +59,7 @@ impl VirtualDom {
///
/// This is useful when a component tree can be driven by external state (IE SSR) but it would be too expensive
/// to toss out the entire tree.
pub fn new_with_props<P: Properties + 'static>(root: FC<P>, root_props: P) -> Self {
pub fn new_with_props<P: Properties + 'static>(_root: FC<P>, _root_props: P) -> Self {
// let mut components = Arena::new();
// let mut components = Arena::new();
@@ -104,7 +95,7 @@ impl VirtualDom {
.expect("Root should always exist")
.run();
let b = Bump::new();
let _b = Bump::new();
let mut diff_machine = DiffMachine::new(&self.diff_bump);
// let mut diff_machine = DiffMachine::new(self, &self.diff_bump, self.base_scope);
@@ -142,7 +133,7 @@ impl VirtualDom {
/// }
///
/// ```
pub fn progress_with_event(&mut self, event: EventTrigger) -> Result<EditList<'_>> {
pub fn progress_with_event(&mut self, _event: EventTrigger) -> Result<EditList<'_>> {
// self.components
// .borrow_mut()
// .get_mut(event.component_id)