fn build_paths(line: &Line, children: &Vec<Tree>) -> Vec<Line> {
  let mut paths = vec![];

  // for each child,
  // create a new line by concatenating `line` and the child point.
  // Then, recursively build all the paths from it's descendants.
  // If there are descendant paths, push those into the paths array.
  // If they are not descendant paths, just push the new line onto the array
  for child in children {
    let path = [&line[..], &[pt2(child.x, child.y)]].concat();

    // I would love a more elegant solve for this...
    if child.children.len() == 0 {
      paths.push(path);
    } else {
      for path in build_paths(&path, &child.children) {
        paths.push(path);
      }
    }
  }

  paths
}
// I don't think this is a great pathfinding algorithm,
// but it seems to work, and I'm OK with that.
// Hopefully I will revisit this in the future.
I don't think this is a great pathfinding algorithm,
but it seems to work, and I'm OK with that.
Hopefully I will revisit this in the future.
I don ' t think this is a great pathfinding algorithm but it seems to work and I ' m OK with that . Hopefully I will revisit this in the future .
fn build_paths(line: &Line, children: &Vec<Tree>) -> Vec<Line> {
  let mut paths = vec![];
  // for each child,
  // create a new line by concatenating `line` and the child point.
  // Then, recursively build all the paths from it's descendants.
  // If there are descendant paths, push those into the paths array.
  // If they are not descendant paths, just push the new line onto the array
  for child in children {
    let path = [&line[..], &[pt2(child.x, child.y)]].concat();
    // I would love a more elegant solve for this...
    if child.children.len() == 0 {
      paths.push(path);
    } else {
      for path in build_paths(&path, &child.children) {
        paths.push(path);
      }
    }
  }
  paths
}
fn build_paths ( line : & Line , children : & Vec < Tree > ) -> Vec < Line > { let mut paths = vec ! [ ] ; // for each child, // create a new line by concatenating `line` and the child point. // Then, recursively build all the paths from it's descendants. // If there are descendant paths, push those into the paths array. // If they are not descendant paths, just push the new line onto the array for child in children { let path = [ & line [ .. ] , & [ pt2 ( child . x , child . y ) ] ] . concat ( ) ; // I would love a more elegant solve for this... if child . children . len ( ) == 0 { paths . push ( path ) ; } else { for path in build_paths ( & path , & child . children ) { paths . push ( path ) ; } } } paths }
I don't think this is a great pathfinding algorithm,
but it seems to work, and I'm OK with that.
I don ' t think this is a great pathfinding algorithm but it seems to work and I ' m OK with that .
line
&Line
children
&Vec<Tree>