IntoVec hasn't actually been necessary in a while due to changes in how I handle component children: this removes a nightly feature

This commit is contained in:
Greg Johnston 2022-10-17 12:59:10 -04:00
parent 7c19dd8039
commit bc8cf4e9fb
3 changed files with 4 additions and 38 deletions

View file

@ -1,6 +1,3 @@
#![feature(auto_traits)]
#![feature(negative_impls)]
#[cfg(any(feature = "csr", feature = "hydrate", feature = "ssr"))]
mod for_component;
mod map;
@ -18,26 +15,3 @@ pub trait Prop {
/// The builder should be automatically generated using the `Prop` derive macro.
fn builder() -> Self::Builder;
}
pub auto trait NotVec {}
impl<T> !NotVec for Vec<T> {}
pub trait IntoVec<T> {
fn into_vec(self) -> Vec<T>;
}
impl<T> IntoVec<T> for T
where
T: NotVec,
{
fn into_vec(self) -> Vec<T> {
vec![self]
}
}
impl<T> IntoVec<T> for Vec<T> {
fn into_vec(self) -> Vec<T> {
self
}
}

View file

@ -5,24 +5,18 @@ use wasm_bindgen::JsCast;
use crate::{use_navigate, use_resolved_path};
#[derive(TypedBuilder)]
pub struct FormProps<C>
where
C: IntoVec<Element>,
{
pub struct FormProps {
#[builder(default, setter(strip_option))]
method: Option<String>,
#[builder(default, setter(strip_option))]
action: Option<String>,
#[builder(default, setter(strip_option))]
enctype: Option<String>,
children: Box<dyn Fn() -> C>,
children: Box<dyn Fn() -> Vec<Element>>,
}
#[allow(non_snake_case)]
pub fn Form<C>(cx: Scope, props: FormProps<C>) -> Element
where
C: IntoVec<Element>,
{
pub fn Form(cx: Scope, props: FormProps) -> Element {
let FormProps {
method,
action,
@ -139,8 +133,6 @@ where
}
};
let children = children().into_vec();
view! { cx,
<form
method=method

View file

@ -36,7 +36,7 @@ where
path: props.path,
loader: props.loader,
action: props.action,
children: props.children.map(|c| c().into_vec()).unwrap_or_default(),
children: props.children.map(|c| c()).unwrap_or_default(),
element: Rc::new(move |cx| (props.element)(cx).into_child(cx)),
}
}