mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 04:33:06 +00:00
fix clippy
This commit is contained in:
parent
4ee4cf23d3
commit
24c626b306
9 changed files with 30 additions and 27 deletions
|
@ -24,7 +24,7 @@ where
|
||||||
{
|
{
|
||||||
RUNTIMES.with(|stack| {
|
RUNTIMES.with(|stack| {
|
||||||
let stack = stack.borrow();
|
let stack = stack.borrow();
|
||||||
stack.last().map(|r| f(&**r))
|
stack.last().map(|r| f(r))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ where
|
||||||
with_runtime(|runtime| {
|
with_runtime(|runtime| {
|
||||||
runtime
|
runtime
|
||||||
.current_scope_id()
|
.current_scope_id()
|
||||||
.and_then(|scope| runtime.get_context(scope).map(|sc| f(&*sc)))
|
.and_then(|scope| runtime.get_context(scope).map(|sc| f(&sc)))
|
||||||
})
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ pub(crate) struct Runtime {
|
||||||
|
|
||||||
impl Runtime {
|
impl Runtime {
|
||||||
pub(crate) fn new(scheduler: Rc<Scheduler>) -> Rc<Self> {
|
pub(crate) fn new(scheduler: Rc<Scheduler>) -> Rc<Self> {
|
||||||
let runtime = Rc::new(Self {
|
Rc::new(Self {
|
||||||
scheduler,
|
scheduler,
|
||||||
|
|
||||||
scope_contexts: Default::default(),
|
scope_contexts: Default::default(),
|
||||||
|
@ -60,8 +60,7 @@ impl Runtime {
|
||||||
scope_stack: Default::default(),
|
scope_stack: Default::default(),
|
||||||
|
|
||||||
rendering: Cell::new(true),
|
rendering: Cell::new(true),
|
||||||
});
|
})
|
||||||
runtime
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a scope context. This slab is synchronized with the scope slab.
|
/// Create a scope context. This slab is synchronized with the scope slab.
|
||||||
|
|
|
@ -158,8 +158,13 @@ fn get_mime_from_path(trimmed: &Path) -> Result<&'static str> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = match infer::get_from_path(trimmed)?.map(|f| f.mime_type()) {
|
let res = match infer::get_from_path(trimmed)?.map(|f| f.mime_type()) {
|
||||||
Some(t) if t == "text/plain" => get_mime_by_ext(trimmed),
|
Some(f) => {
|
||||||
Some(f) => f,
|
if f == "text/plain" {
|
||||||
|
get_mime_by_ext(trimmed)
|
||||||
|
} else {
|
||||||
|
f
|
||||||
|
}
|
||||||
|
}
|
||||||
None => get_mime_by_ext(trimmed),
|
None => get_mime_by_ext(trimmed),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use dioxus::{events::MouseData, prelude::*};
|
use dioxus::{events::MouseData, prelude::*};
|
||||||
use dioxus_core::Event;
|
use dioxus_core::Event;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
use std::fmt::Write;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -9,7 +10,12 @@ fn main() {
|
||||||
|
|
||||||
fn app(cx: Scope) -> Element {
|
fn app(cx: Scope) -> Element {
|
||||||
fn to_str(c: &[i32; 3]) -> String {
|
fn to_str(c: &[i32; 3]) -> String {
|
||||||
"#".to_string() + &c.iter().map(|c| format!("{c:02X?}")).collect::<String>()
|
let mut result = String::new();
|
||||||
|
result += "#";
|
||||||
|
for c in c.iter() {
|
||||||
|
write!(string, "{c:02X?}").unwrap();
|
||||||
|
}
|
||||||
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_brightness(m: &Rc<MouseData>) -> i32 {
|
fn get_brightness(m: &Rc<MouseData>) -> i32 {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! Tracked and computed state in Dioxus
|
||||||
|
|
||||||
use dioxus_core::{ScopeId, ScopeState};
|
use dioxus_core::{ScopeId, ScopeState};
|
||||||
use slab::Slab;
|
use slab::Slab;
|
||||||
use std::{
|
use std::{
|
||||||
|
|
|
@ -52,8 +52,7 @@ macro_rules! to_owned {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
mod computed;
|
pub mod computed;
|
||||||
pub use computed::*;
|
|
||||||
|
|
||||||
mod use_on_unmount;
|
mod use_on_unmount;
|
||||||
pub use use_on_unmount::*;
|
pub use use_on_unmount::*;
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub fn use_eval(cx: &ScopeState) -> &EvalCreator {
|
||||||
Rc::new(move |script: &str| {
|
Rc::new(move |script: &str| {
|
||||||
eval_provider
|
eval_provider
|
||||||
.new_evaluator(script.to_string())
|
.new_evaluator(script.to_string())
|
||||||
.map(|evaluator| UseEval::new(evaluator))
|
.map(UseEval::new)
|
||||||
}) as Rc<dyn Fn(&str) -> Result<UseEval, EvalError>>
|
}) as Rc<dyn Fn(&str) -> Result<UseEval, EvalError>>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -446,7 +446,6 @@ impl<V: FromAnyValue + Send + Sync> RealDom<V> {
|
||||||
drop(tree);
|
drop(tree);
|
||||||
children.reverse();
|
children.reverse();
|
||||||
if let Some(node) = self.get_mut(id) {
|
if let Some(node) = self.get_mut(id) {
|
||||||
let node = node;
|
|
||||||
f(node);
|
f(node);
|
||||||
stack.extend(children.iter());
|
stack.extend(children.iter());
|
||||||
}
|
}
|
||||||
|
|
|
@ -288,10 +288,7 @@ impl DynamicMapping {
|
||||||
let idx = self.last_attribute_idx;
|
let idx = self.last_attribute_idx;
|
||||||
self.last_attribute_idx += 1;
|
self.last_attribute_idx += 1;
|
||||||
|
|
||||||
self.attribute_to_idx
|
self.attribute_to_idx.entry(attr).or_default().push(idx);
|
||||||
.entry(attr)
|
|
||||||
.or_insert_with(Vec::new)
|
|
||||||
.push(idx);
|
|
||||||
|
|
||||||
idx
|
idx
|
||||||
}
|
}
|
||||||
|
@ -300,10 +297,7 @@ impl DynamicMapping {
|
||||||
let idx = self.last_element_idx;
|
let idx = self.last_element_idx;
|
||||||
self.last_element_idx += 1;
|
self.last_element_idx += 1;
|
||||||
|
|
||||||
self.node_to_idx
|
self.node_to_idx.entry(node).or_default().push(idx);
|
||||||
.entry(node)
|
|
||||||
.or_insert_with(Vec::new)
|
|
||||||
.push(idx);
|
|
||||||
|
|
||||||
idx
|
idx
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,9 +50,11 @@ pub fn use_signal<T: 'static>(cx: &ScopeState, f: impl FnOnce() -> T) -> Signal<
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct Unsubscriber {
|
struct Unsubscriber {
|
||||||
scope: ScopeId,
|
scope: ScopeId,
|
||||||
subscribers: Rc<RefCell<Vec<Rc<RefCell<Vec<ScopeId>>>>>>,
|
subscribers: UnsubscriberArray,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UnsubscriberArray = Rc<RefCell<Vec<Rc<RefCell<Vec<ScopeId>>>>>>;
|
||||||
|
|
||||||
impl Drop for Unsubscriber {
|
impl Drop for Unsubscriber {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
for subscribers in self.subscribers.borrow().iter() {
|
for subscribers in self.subscribers.borrow().iter() {
|
||||||
|
@ -269,10 +271,7 @@ impl<'a, T: 'static, I: 'static> Write<'a, T, I> {
|
||||||
) -> Option<Write<'a, O, I>> {
|
) -> Option<Write<'a, O, I>> {
|
||||||
let Self { write, signal } = myself;
|
let Self { write, signal } = myself;
|
||||||
let write = RefMut::filter_map(write, f).ok();
|
let write = RefMut::filter_map(write, f).ok();
|
||||||
write.map(|write| Write {
|
write.map(|write| Write { write, signal })
|
||||||
write,
|
|
||||||
signal: signal,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,13 +279,13 @@ impl<'a, T: 'static> Deref for Write<'a, T> {
|
||||||
type Target = T;
|
type Target = T;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
&*self.write
|
&self.write
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> DerefMut for Write<'_, T> {
|
impl<T> DerefMut for Write<'_, T> {
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
&mut *self.write
|
&mut self.write
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue