generated from mitchell/rust_template
context is now a Rc
This commit is contained in:
parent
da84bdbb27
commit
bbde4d6331
@ -33,7 +33,7 @@ impl<FD: FormToolData> Clone for ButtonData<FD> {
|
||||
impl<FD: FormToolData> FormBuilder<FD> {
|
||||
pub fn button(mut self, builder: impl BuilderFn<ButtonBuilder<FD>, FD::Context>) -> Self {
|
||||
let button_builder = ButtonBuilder::new();
|
||||
let control = builder(button_builder, &self.cx);
|
||||
let control = builder(button_builder, self.cx.clone());
|
||||
|
||||
let render_data = ControlRenderData {
|
||||
data: control.data,
|
||||
|
||||
@ -18,7 +18,7 @@ pub mod submit;
|
||||
pub mod text_area;
|
||||
pub mod text_input;
|
||||
|
||||
pub trait BuilderFn<B, CX>: Fn(B, &CX) -> B {}
|
||||
pub trait BuilderFn<B, CX>: Fn(B, Rc<CX>) -> B {}
|
||||
pub trait ValidationFn<FDT: ?Sized>: Fn(&FDT) -> Result<(), String> + 'static {}
|
||||
pub trait ValidationCb: Fn() -> bool + 'static {}
|
||||
pub trait ParseFn<CR, FDT>: Fn(CR) -> Result<FDT, String> + 'static {}
|
||||
@ -32,7 +32,7 @@ pub trait RenderFn<FS, FD: 'static>:
|
||||
}
|
||||
|
||||
// implement the traits for all valid types
|
||||
impl<B, CX, T> BuilderFn<B, CX> for T where T: Fn(B, &CX) -> B {}
|
||||
impl<B, CX, T> BuilderFn<B, CX> for T where T: Fn(B, Rc<CX>) -> B {}
|
||||
impl<FDT, T> ValidationFn<FDT> for T where T: Fn(&FDT) -> Result<(), String> + 'static {}
|
||||
impl<T> ValidationCb for T where T: Fn() -> bool + 'static {}
|
||||
impl<CR, FDT, F> ParseFn<CR, FDT> for F where F: Fn(CR) -> Result<FDT, String> + 'static {}
|
||||
|
||||
@ -66,7 +66,7 @@ impl<FD: FormToolData> FormBuilder<FD> {
|
||||
builder: impl BuilderFn<VanityControlBuilder<FD, C>, FD::Context>,
|
||||
) -> Self {
|
||||
let vanity_builder = VanityControlBuilder::new(C::default());
|
||||
let control = builder(vanity_builder, &self.cx);
|
||||
let control = builder(vanity_builder, self.cx.clone());
|
||||
self.add_vanity(control);
|
||||
self
|
||||
}
|
||||
@ -76,7 +76,7 @@ impl<FD: FormToolData> FormBuilder<FD> {
|
||||
builder: impl BuilderFn<ControlBuilder<FD, C, FDT>, FD::Context>,
|
||||
) -> Self {
|
||||
let control_builder = ControlBuilder::new(C::default());
|
||||
let control = builder(control_builder, &self.cx);
|
||||
let control = builder(control_builder, self.cx.clone());
|
||||
self.add_control(control);
|
||||
self
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user