mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 14:54:16 +00:00
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:
parent
7c19dd8039
commit
bc8cf4e9fb
3 changed files with 4 additions and 38 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue