Skip to content

Commit

Permalink
Remove a prefix from a method name by manually resolving methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Cameron Zwarich committed Oct 1, 2014
1 parent 6358b7d commit 4ef0f39
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
10 changes: 8 additions & 2 deletions components/layout/wrapper.rs
Expand Up @@ -213,8 +213,14 @@ impl<'ln> LayoutNode<'ln> {

/// Returns an iterator over this node's children.
pub fn children(&self) -> LayoutNodeChildrenIterator<'ln> {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn first_child<T: TLayoutNode>(this: &T) -> Option<T> {
this.first_child()
}

LayoutNodeChildrenIterator {
current_node: self.first_child(),
current_node: first_child(self),
}
}

Expand Down Expand Up @@ -247,7 +253,7 @@ impl<'ln> TNode<'ln, LayoutElement<'ln>> for LayoutNode<'ln> {
}
}

fn tnode_first_child(&self) -> Option<LayoutNode<'ln>> {
fn first_child(&self) -> Option<LayoutNode<'ln>> {
unsafe {
self.node.first_child_ref().map(|node| self.new_with_this_lifetime(&node))
}
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/node.rs
Expand Up @@ -2039,7 +2039,7 @@ impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> {
(self as &NodeHelpers).parent_node().map(|node| *node.root())
}

fn tnode_first_child(&self) -> Option<JSRef<'a, Node>> {
fn first_child(&self) -> Option<JSRef<'a, Node>> {
(self as &NodeHelpers).first_child().map(|node| *node.root())
}

Expand Down
3 changes: 1 addition & 2 deletions components/style/node.rs
Expand Up @@ -11,8 +11,7 @@ use string_cache::{Atom, Namespace};

pub trait TNode<'a, E: TElement<'a>> : Clone {
fn parent_node(&self) -> Option<Self>;
/// Name is prefixed to avoid a conflict with TLayoutNode.
fn tnode_first_child(&self) -> Option<Self>;
fn first_child(&self) -> Option<Self>;
fn prev_sibling(&self) -> Option<Self>;
fn next_sibling(&self) -> Option<Self>;
fn is_document(&self) -> bool;
Expand Down

0 comments on commit 4ef0f39

Please sign in to comment.