update
This commit is contained in:
parent
cd3d4a5a6d
commit
8887eb07c1
2 changed files with 149 additions and 165 deletions
|
@ -55,6 +55,36 @@ impl DivWidget {
|
|||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn push_if<T: UIWidget + 'static, U: Fn() -> T>(
|
||||
mut self,
|
||||
condition: bool,
|
||||
then: U,
|
||||
) -> Self {
|
||||
if condition {
|
||||
self.0.push(Box::new(then()));
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn push_for<
|
||||
'a,
|
||||
T: UIWidget + 'static,
|
||||
X: 'a,
|
||||
U: Fn(&X) -> T,
|
||||
I: IntoIterator<Item = &'a X>,
|
||||
>(
|
||||
mut self,
|
||||
iterator: I,
|
||||
then: U,
|
||||
) -> Self {
|
||||
for val in iterator {
|
||||
self.0.push(Box::new(then(val)));
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Extract the `<div>`s innerHTML
|
||||
///
|
||||
/// This will render `<content>` instead of `<div> <content> </div>`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue