mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-18 16:20:18 +00:00
use ToOwned trait instead of inherent method
This commit is contained in:
parent
b308375b82
commit
2e354f480b
4 changed files with 523 additions and 8 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue