pub struct ObjectBuilder<'a, O> { /* private fields */ }
Implementations§
Source§impl<'a, O: IsA<Object> + IsClass> ObjectBuilder<'a, O>
impl<'a, O: IsA<Object> + IsClass> ObjectBuilder<'a, O>
Sourcepub fn property(self, name: &'a str, value: impl Into<Value>) -> Self
pub fn property(self, name: &'a str, value: impl Into<Value>) -> Self
Sets property name
to the given value value
.
Overrides any default or previously defined value for name
.
Sourcepub fn property_if(
self,
name: &'a str,
value: impl Into<Value>,
predicate: bool,
) -> Self
pub fn property_if( self, name: &'a str, value: impl Into<Value>, predicate: bool, ) -> Self
Sets property name
to the given inner value if the predicate
evaluates to true
.
This has no effect if the predicate
evaluates to false
,
i.e. default or previous value for name
is kept.
Sourcepub fn property_if_some(
self,
name: &'a str,
value: Option<impl Into<Value>>,
) -> Self
pub fn property_if_some( self, name: &'a str, value: Option<impl Into<Value>>, ) -> Self
Sets property name
to the given inner value if value
is Some
.
This has no effect if the value is None
, i.e. default or previous value for name
is kept.
Sourcepub fn property_from_iter<V: ValueType + Into<Value> + FromIterator<Value>>(
self,
name: &'a str,
iter: impl IntoIterator<Item = impl Into<Value>>,
) -> Self
pub fn property_from_iter<V: ValueType + Into<Value> + FromIterator<Value>>( self, name: &'a str, iter: impl IntoIterator<Item = impl Into<Value>>, ) -> Self
Sets property name
using the given ValueType
V
built from iter
’s the Item
s.
Overrides any default or previously defined value for name
.
Sourcepub fn property_if_not_empty<V: ValueType + Into<Value> + FromIterator<Value>>(
self,
name: &'a str,
iter: impl IntoIterator<Item = impl Into<Value>>,
) -> Self
pub fn property_if_not_empty<V: ValueType + Into<Value> + FromIterator<Value>>( self, name: &'a str, iter: impl IntoIterator<Item = impl Into<Value>>, ) -> Self
Sets property name
using the given ValueType
V
built from iter
’s Items, if
iter` is not empty.
This has no effect if iter
is empty, i.e. previous property value for name
is unchanged.