From bbde4d633123e4c78fae350907314f7002f5fda1 Mon Sep 17 00:00:00 2001 From: Mitchell M Date: Tue, 18 Jun 2024 13:10:49 -0500 Subject: [PATCH] context is now a Rc --- src/controls/button.rs | 2 +- src/controls/mod.rs | 4 ++-- src/form_builder.rs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/controls/button.rs b/src/controls/button.rs index 002eefd..cd56d7c 100644 --- a/src/controls/button.rs +++ b/src/controls/button.rs @@ -33,7 +33,7 @@ impl Clone for ButtonData { impl FormBuilder { pub fn button(mut self, builder: impl BuilderFn, 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, diff --git a/src/controls/mod.rs b/src/controls/mod.rs index 9a0cc43..f01d62f 100644 --- a/src/controls/mod.rs +++ b/src/controls/mod.rs @@ -18,7 +18,7 @@ pub mod submit; pub mod text_area; pub mod text_input; -pub trait BuilderFn: Fn(B, &CX) -> B {} +pub trait BuilderFn: Fn(B, Rc) -> B {} pub trait ValidationFn: Fn(&FDT) -> Result<(), String> + 'static {} pub trait ValidationCb: Fn() -> bool + 'static {} pub trait ParseFn: Fn(CR) -> Result + 'static {} @@ -32,7 +32,7 @@ pub trait RenderFn: } // implement the traits for all valid types -impl BuilderFn for T where T: Fn(B, &CX) -> B {} +impl BuilderFn for T where T: Fn(B, Rc) -> B {} impl ValidationFn for T where T: Fn(&FDT) -> Result<(), String> + 'static {} impl ValidationCb for T where T: Fn() -> bool + 'static {} impl ParseFn for F where F: Fn(CR) -> Result + 'static {} diff --git a/src/form_builder.rs b/src/form_builder.rs index 6dd8108..6d2fd47 100644 --- a/src/form_builder.rs +++ b/src/form_builder.rs @@ -66,7 +66,7 @@ impl FormBuilder { builder: impl BuilderFn, 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 FormBuilder { builder: impl BuilderFn, 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 }