Introduce splits method in pane_grid::Node
This commit is contained in:
parent
cb530ccf2f
commit
23f753e599
1 changed files with 24 additions and 0 deletions
|
|
@ -43,6 +43,30 @@ pub enum Node {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Node {
|
impl Node {
|
||||||
|
/// Returns an iterator over each [`Split`] in this [`Node`].
|
||||||
|
///
|
||||||
|
/// [`Split`]: struct.Split.html
|
||||||
|
/// [`Node`]: enum.Node.html
|
||||||
|
pub fn splits(&self) -> impl Iterator<Item = &Split> {
|
||||||
|
let mut unvisited_nodes = vec![self];
|
||||||
|
|
||||||
|
std::iter::from_fn(move || {
|
||||||
|
while let Some(node) = unvisited_nodes.pop() {
|
||||||
|
match node {
|
||||||
|
Node::Split { id, a, b, .. } => {
|
||||||
|
unvisited_nodes.push(a);
|
||||||
|
unvisited_nodes.push(b);
|
||||||
|
|
||||||
|
return Some(id);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
None
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the rectangular region for each [`Pane`] in the [`Node`] given
|
/// Returns the rectangular region for each [`Pane`] in the [`Node`] given
|
||||||
/// the spacing between panes and the total available space.
|
/// the spacing between panes and the total available space.
|
||||||
///
|
///
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue