Skip to content

Commit

Permalink
Add VTag::into_children (#2638)
Browse files Browse the repository at this point in the history
* Add `VTag::into_children`

Currently, VTag supports `children` and `children_mut`, but not `into_children` to complete the pattern. This is useful if someone wishes to destructively acquire the children of a VTag to reparent them to a different VTag.

* Repair broken doc comment on `VTag::children_mut`

* Remove spaces between functions
  • Loading branch information
LLBlumire committed Apr 23, 2022
1 parent 1794dd0 commit 2db4c81
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/yew/src/virtual_dom/vtag.rs
Expand Up @@ -297,14 +297,22 @@ impl VTag {
}

/// Returns a mutable reference to the children of this [VTag], if the node can have
// children
/// children
pub fn children_mut(&mut self) -> Option<&mut VList> {
match &mut self.inner {
VTagInner::Other { children, .. } => Some(children),
_ => None,
}
}

/// Returns the children of this [VTag]
pub fn into_children(self) -> VList {
match self.inner {
VTagInner::Other { children, .. } => children,
_ => VList::new(),
}
}

/// Returns the `value` of an
/// [InputElement](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input) or
/// [TextArea](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea)
Expand Down

1 comment on commit 2db4c81

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yew master branch benchmarks (Lower is better)

Benchmark suite Current: 2db4c81 Previous: 1794dd0 Ratio
yew-struct-keyed 01_run1k 213.484 151.3435 1.41
yew-struct-keyed 02_replace1k 233.5825 182.322 1.28
yew-struct-keyed 03_update10th1k_x16 363.8455 370.773 0.98
yew-struct-keyed 04_select1k 74.9975 75.88300000000001 0.99
yew-struct-keyed 05_swap1k 100.34 94.9265 1.06
yew-struct-keyed 06_remove-one-1k 35.014 26.405 1.33
yew-struct-keyed 07_create10k 3303.7455 2680.001 1.23
yew-struct-keyed 08_create1k-after1k_x2 470.1945 372.004 1.26
yew-struct-keyed 09_clear1k_x8 208.8745 176.013 1.19
yew-struct-keyed 21_ready-memory 1.457233428955078 1.4529380798339844 1.00
yew-struct-keyed 22_run-memory 1.6601448059082031 1.708660125732422 0.97
yew-struct-keyed 23_update5-memory 1.668548583984375 1.6635246276855469 1.00
yew-struct-keyed 24_run5-memory 1.9439773559570312 1.944427490234375 1.00
yew-struct-keyed 25_run-clear-memory 1.3280982971191406 1.328044891357422 1.00
yew-struct-keyed 31_startup-ci 1881.945 1746.692 1.08
yew-struct-keyed 32_startup-bt 32.596000000000004 26.22799999999999 1.24
yew-struct-keyed 33_startup-mainthreadcost 240.072 204.9360000000001 1.17
yew-struct-keyed 34_startup-totalbytes 328.7392578125 328.7392578125 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.