fix some clippy lints
This commit is contained in:
1 parent
76a050314a
commit
ee25c03e74
9 files changed
+25
-14
No files matched your search
@@ -139,7 +139,6 @@ Missing Features
|
|||||||
Missing examples
|
Missing examples
|
||||||
- Shared state
|
- Shared state
|
||||||
- Root-less element groups
|
- Root-less element groups
|
||||||
- Spread props
|
|
||||||
- Custom elements
|
- Custom elements
|
||||||
- Component Children: Pass children into child components
|
- Component Children: Pass children into child components
|
||||||
- Render To string: Render a mounted virtualdom to a string
|
- Render To string: Render a mounted virtualdom to a string
|
||||||
|
|||||||
+1
-2
@@ -21,10 +21,9 @@ fn app(cx: Scope) -> Element {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn Component<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
|
fn Component<'a>(cx: Scope<'a, Props<'a>>) -> Element<'a> {
|
||||||
let attributes = &*cx.props.attributes;
|
|
||||||
render! {
|
render! {
|
||||||
audio {
|
audio {
|
||||||
..attributes,
|
..cx.props.attributes,
|
||||||
"1: {cx.props.extra_data}\n2: {cx.props.extra_data2}"
|
"1: {cx.props.extra_data}\n2: {cx.props.extra_data2}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -894,12 +894,14 @@ Finally, call `.build()` to create the instance of `{name}`.
|
|||||||
path.span(),
|
path.span(),
|
||||||
);
|
);
|
||||||
quote! {
|
quote! {
|
||||||
|
#[allow(dead_code, non_camel_case_types, missing_docs)]
|
||||||
impl #impl_generics dioxus_elements::extensions::#marker_name < #extend_lifetime > for #builder_name < #( #ty_generics ),* > #where_clause {}
|
impl #impl_generics dioxus_elements::extensions::#marker_name < #extend_lifetime > for #builder_name < #( #ty_generics ),* > #where_clause {}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(quote! {
|
Ok(quote! {
|
||||||
impl #impl_generics ::dioxus::prelude::HasAttributesBox<#extend_lifetime> for #builder_name < #( #ty_generics ),* > #where_clause {
|
#[allow(dead_code, non_camel_case_types, missing_docs)]
|
||||||
|
impl #impl_generics ::dioxus::prelude::HasAttributes<#extend_lifetime> for #builder_name < #( #ty_generics ),* > #where_clause {
|
||||||
fn push_attribute(
|
fn push_attribute(
|
||||||
mut self,
|
mut self,
|
||||||
name: &#extend_lifetime str,
|
name: &#extend_lifetime str,
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ pub(crate) mod innerlude {
|
|||||||
pub use crate::innerlude::{
|
pub use crate::innerlude::{
|
||||||
fc_to_builder, vdom_is_rendering, AnyValue, Attribute, AttributeType, AttributeValue,
|
fc_to_builder, vdom_is_rendering, AnyValue, Attribute, AttributeType, AttributeValue,
|
||||||
BorrowedAttributeValue, CapturedError, Component, DynamicNode, Element, ElementId, Event,
|
BorrowedAttributeValue, CapturedError, Component, DynamicNode, Element, ElementId, Event,
|
||||||
Fragment, HasAttributesBox, IntoDynNode, LazyNodes, MountedAttribute, Mutation, Mutations,
|
Fragment, HasAttributes, IntoDynNode, LazyNodes, MountedAttribute, Mutation, Mutations,
|
||||||
Properties, RenderReturn, Scope, ScopeId, ScopeState, Scoped, TaskId, Template,
|
Properties, RenderReturn, Scope, ScopeId, ScopeState, Scoped, TaskId, Template,
|
||||||
TemplateAttribute, TemplateNode, VComponent, VNode, VPlaceholder, VText, VirtualDom,
|
TemplateAttribute, TemplateNode, VComponent, VNode, VPlaceholder, VText, VirtualDom,
|
||||||
};
|
};
|
||||||
@@ -89,10 +89,10 @@ pub mod prelude {
|
|||||||
consume_context, consume_context_from_scope, current_scope_id, fc_to_builder, has_context,
|
consume_context, consume_context_from_scope, current_scope_id, fc_to_builder, has_context,
|
||||||
provide_context, provide_context_to_scope, provide_root_context, push_future,
|
provide_context, provide_context_to_scope, provide_root_context, push_future,
|
||||||
remove_future, schedule_update_any, spawn, spawn_forever, suspend, throw, AnyValue,
|
remove_future, schedule_update_any, spawn, spawn_forever, suspend, throw, AnyValue,
|
||||||
Attribute, AttributeType, Component, Element, Event, EventHandler, Fragment,
|
Attribute, AttributeType, Component, Element, Event, EventHandler, Fragment, HasAttributes,
|
||||||
HasAttributesBox, IntoAttributeValue, LazyNodes, MountedAttribute, Properties, Runtime,
|
IntoAttributeValue, LazyNodes, MountedAttribute, Properties, Runtime, RuntimeGuard, Scope,
|
||||||
RuntimeGuard, Scope, ScopeId, ScopeState, Scoped, TaskId, Template, TemplateAttribute,
|
ScopeId, ScopeState, Scoped, TaskId, Template, TemplateAttribute, TemplateNode, Throw,
|
||||||
TemplateNode, Throw, VNode, VirtualDom,
|
VNode, VirtualDom,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -414,6 +414,7 @@ pub enum TemplateAttribute<'a> {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An attribute with information about its position in the DOM and the element it was mounted to
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MountedAttribute<'a> {
|
pub struct MountedAttribute<'a> {
|
||||||
pub(crate) ty: AttributeType<'a>,
|
pub(crate) ty: AttributeType<'a>,
|
||||||
@@ -440,6 +441,12 @@ impl<'a> From<&'a [Attribute<'a>]> for MountedAttribute<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> From<&'a Vec<Attribute<'a>>> for MountedAttribute<'a> {
|
||||||
|
fn from(attr: &'a Vec<Attribute<'a>>) -> Self {
|
||||||
|
attr.as_slice().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> MountedAttribute<'a> {
|
impl<'a> MountedAttribute<'a> {
|
||||||
/// Get the type of this attribute
|
/// Get the type of this attribute
|
||||||
pub fn attribute_type(&self) -> &AttributeType<'a> {
|
pub fn attribute_type(&self) -> &AttributeType<'a> {
|
||||||
@@ -487,8 +494,10 @@ impl<'a> Attribute<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The type of an attribute
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum AttributeType<'a> {
|
pub enum AttributeType<'a> {
|
||||||
|
/// A single attribute
|
||||||
Single(Attribute<'a>),
|
Single(Attribute<'a>),
|
||||||
/// Many different attributes sorted by name
|
/// Many different attributes sorted by name
|
||||||
Many(&'a [Attribute<'a>]),
|
Many(&'a [Attribute<'a>]),
|
||||||
@@ -899,7 +908,9 @@ impl<'a, T: IntoAttributeValue<'a>> IntoAttributeValue<'a> for Option<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HasAttributesBox<'a> {
|
/// A trait for anything that has a dynamic list of attributes
|
||||||
|
pub trait HasAttributes<'a> {
|
||||||
|
/// Push an attribute onto the list of attributes
|
||||||
fn push_attribute(
|
fn push_attribute(
|
||||||
self,
|
self,
|
||||||
name: &'a str,
|
name: &'a str,
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ impl ToTokens for ImplExtensionAttributes {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
tokens.append_all(quote! {
|
tokens.append_all(quote! {
|
||||||
pub trait #extension_name<'a>: HasAttributesBox<'a> + Sized {
|
pub trait #extension_name<'a>: HasAttributes<'a> + Sized {
|
||||||
#(#impls)*
|
#(#impls)*
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#![allow(non_upper_case_globals)]
|
#![allow(non_upper_case_globals)]
|
||||||
|
|
||||||
use dioxus_core::prelude::IntoAttributeValue;
|
use dioxus_core::prelude::IntoAttributeValue;
|
||||||
use dioxus_core::HasAttributesBox;
|
use dioxus_core::HasAttributes;
|
||||||
use dioxus_html_internal_macro::impl_extension_attributes;
|
use dioxus_html_internal_macro::impl_extension_attributes;
|
||||||
#[cfg(feature = "hot-reload-context")]
|
#[cfg(feature = "hot-reload-context")]
|
||||||
use dioxus_rsx::HotReloadingContext;
|
use dioxus_rsx::HotReloadingContext;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#![allow(non_upper_case_globals)]
|
#![allow(non_upper_case_globals)]
|
||||||
|
|
||||||
use dioxus_core::prelude::IntoAttributeValue;
|
use dioxus_core::prelude::IntoAttributeValue;
|
||||||
use dioxus_core::HasAttributesBox;
|
use dioxus_core::HasAttributes;
|
||||||
use dioxus_html_internal_macro::impl_extension_attributes;
|
use dioxus_html_internal_macro::impl_extension_attributes;
|
||||||
|
|
||||||
use crate::AttributeDiscription;
|
use crate::AttributeDiscription;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ impl ToTokens for AttributeType {
|
|||||||
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
||||||
match self {
|
match self {
|
||||||
AttributeType::Named(n) => tokens.append_all(quote! { #n }),
|
AttributeType::Named(n) => tokens.append_all(quote! { #n }),
|
||||||
AttributeType::Spread(e) => tokens.append_all(quote! { #e.into() }),
|
AttributeType::Spread(e) => tokens.append_all(quote! { (&#e).into() }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user