pub trait Props {
type Builder;
// Required method
fn builder() -> Self::Builder;
}
Expand description
A trait that is implemented automatically by the Props
derive macro.
This is used when constructing components in the view!
macro.
§Example
Deriving an implementation and using the builder to construct an instance of the struct:
#[derive(Props)]
struct ButtonProps {
color: String,
disabled: bool,
}
let builder = <ButtonProps as Props>::builder();
let button_props = builder.color("red".to_string()).disabled(false).build();
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl Props for ()
Make sure that the Props
trait is implemented for ()
so that components without props can be
thought as accepting props of type ()
.
impl Props for ()
Make sure that the Props
trait is implemented for ()
so that components without props can be
thought as accepting props of type ()
.