From d1c6e186bfad1599c9605ff3b39e66b06f920cd5 Mon Sep 17 00:00:00 2001 From: "Brian J. Burg" Date: Sat, 13 Oct 2012 18:13:44 -0700 Subject: [PATCH] Add some helper methods to util::tree for accessing tree fields (it wasn't possible before due to multiple with_tree_fields implementations) --- src/servo/util/tree.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/servo/util/tree.rs b/src/servo/util/tree.rs index 1436a92707e..2f58c8c4d56 100644 --- a/src/servo/util/tree.rs +++ b/src/servo/util/tree.rs @@ -34,6 +34,26 @@ pub fn each_child>(ops: &O, node: &T, f: fn(&T) -> bool) } } +pub fn first_child>(ops: &O, node: &T) -> Option { + ops.with_tree_fields(node, |tf| tf.first_child) +} + +pub fn last_child>(ops: &O, node: &T) -> Option { + ops.with_tree_fields(node, |tf| tf.last_child) +} + +pub fn next_sibling>(ops: &O, node: &T) -> Option { + ops.with_tree_fields(node, |tf| tf.next_sibling) +} + +pub fn prev_sibling>(ops: &O, node: &T) -> Option { + ops.with_tree_fields(node, |tf| tf.prev_sibling) +} + +pub fn parent>(ops: &O, node: &T) -> Option { + ops.with_tree_fields(node, |tf| tf.parent) +} + pub fn empty() -> Tree { {mut parent: None, mut first_child: None,