generated from mitchell/rust_template
41 lines
1.3 KiB
Rust
41 lines
1.3 KiB
Rust
use super::{BuilderCxFn, BuilderFn, ControlBuilder, ControlData};
|
|
use crate::{FormBuilder, FormToolData};
|
|
|
|
impl<FD: FormToolData> FormBuilder<FD> {
|
|
pub fn custom<CC: ControlData, FDT: Clone + PartialEq + 'static>(
|
|
mut self,
|
|
control_data: CC,
|
|
builder: impl BuilderFn<ControlBuilder<FD, CC, FDT>>,
|
|
) -> Self {
|
|
let control_builder = ControlBuilder::new(control_data);
|
|
let control = builder(control_builder);
|
|
self.add_control(control);
|
|
self
|
|
}
|
|
|
|
pub fn custom_cx<CC: ControlData, FDT: Clone + PartialEq + 'static>(
|
|
mut self,
|
|
control_data: CC,
|
|
builder: impl BuilderCxFn<ControlBuilder<FD, CC, FDT>, FD::Context>,
|
|
) -> Self {
|
|
let control_builder = ControlBuilder::new(control_data);
|
|
let control = builder(control_builder, self.cx.clone());
|
|
self.add_control(control);
|
|
self
|
|
}
|
|
|
|
pub fn custom_default<CC: Default + ControlData, FDT: Clone + PartialEq + 'static>(
|
|
self,
|
|
builder: impl BuilderFn<ControlBuilder<FD, CC, FDT>>,
|
|
) -> Self {
|
|
self.new_control(builder)
|
|
}
|
|
|
|
pub fn custom_default_cx<CC: Default + ControlData, FDT: Clone + PartialEq + 'static>(
|
|
self,
|
|
builder: impl BuilderCxFn<ControlBuilder<FD, CC, FDT>, FD::Context>,
|
|
) -> Self {
|
|
self.new_control_cx(builder)
|
|
}
|
|
}
|