mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-18 00:00:03 +00:00
Merge #633
633: use ToOwned trait instead of inherent method r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
1d4b421aad
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