PropsBuilder: use from trait
This commit is contained in:
parent
5c9cb7eece
commit
db0c54b781
|
@ -201,7 +201,7 @@ impl Component for FileList {
|
|||
/// This returns a prop builder in order to make easier to create
|
||||
/// new properties for the element.
|
||||
fn get_props(&self) -> PropsBuilder {
|
||||
PropsBuilder::from_props(&self.props)
|
||||
PropsBuilder::from(self.props.clone())
|
||||
}
|
||||
|
||||
/// ### on
|
||||
|
|
|
@ -214,7 +214,7 @@ impl Component for Input {
|
|||
/// This returns a prop builder in order to make easier to create
|
||||
/// new properties for the element.
|
||||
fn get_props(&self) -> PropsBuilder {
|
||||
PropsBuilder::from_props(&self.props)
|
||||
PropsBuilder::from(self.props.clone())
|
||||
}
|
||||
|
||||
/// ### on
|
||||
|
|
|
@ -180,7 +180,7 @@ impl Component for RadioGroup {
|
|||
/// This returns a prop builder in order to make easier to create
|
||||
/// new properties for the element.
|
||||
fn get_props(&self) -> PropsBuilder {
|
||||
PropsBuilder::from_props(&self.props)
|
||||
PropsBuilder::from(self.props.clone())
|
||||
}
|
||||
|
||||
/// ### on
|
||||
|
|
|
@ -95,15 +95,6 @@ pub struct PropsBuilder {
|
|||
}
|
||||
|
||||
impl PropsBuilder {
|
||||
/// ### from_props
|
||||
///
|
||||
/// Create a props builder from existing properties
|
||||
pub fn from_props(props: &Props) -> Self {
|
||||
PropsBuilder {
|
||||
props: Some(props.clone()),
|
||||
}
|
||||
}
|
||||
|
||||
/// ### build
|
||||
///
|
||||
/// Build Props from builder
|
||||
|
@ -222,6 +213,12 @@ impl PropsBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Props> for PropsBuilder {
|
||||
fn from(props: Props) -> Self {
|
||||
PropsBuilder { props: Some(props) }
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for PropsBuilder {
|
||||
fn default() -> Self {
|
||||
PropsBuilder {
|
||||
|
@ -413,7 +410,7 @@ mod tests {
|
|||
))
|
||||
.build();
|
||||
// Ok, now make a builder from properties
|
||||
let builder: PropsBuilder = PropsBuilder::from_props(&props);
|
||||
let builder: PropsBuilder = PropsBuilder::from(props);
|
||||
assert!(builder.props.is_some());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue