use ToOwned trait instead of inherent method

This commit is contained in:
Aleksey Kladov 2019-01-25 02:09:31 +03:00
parent b308375b82
commit 2e354f480b
4 changed files with 523 additions and 8 deletions

View file

@ -15,12 +15,13 @@ use crate::{
/// conversion itself has zero runtime cost: ast and syntax nodes have exactly
/// the same representation: a pointer to the tree root and a pointer to the
/// node itself.
pub trait AstNode: rowan::TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> {
pub trait AstNode:
rowan::TransparentNewType<Repr = rowan::SyntaxNode<RaTypes>> + ToOwned<Owned = TreeArc<Self>>
{
fn cast(syntax: &SyntaxNode) -> Option<&Self>
where
Self: Sized;
fn syntax(&self) -> &SyntaxNode;
fn to_owned(&self) -> TreeArc<Self>;
}
pub trait AstToken: AstNode {