mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Merge #625
625: minor rename r=matklad a=matklad Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
eaef729377
1 changed files with 4 additions and 4 deletions
|
@ -42,7 +42,7 @@ impl SyntaxNodePtr {
|
||||||
/// Like `SyntaxNodePtr`, but remembers the type of node
|
/// Like `SyntaxNodePtr`, but remembers the type of node
|
||||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct AstPtr<N: AstNode> {
|
pub struct AstPtr<N: AstNode> {
|
||||||
ptr: SyntaxNodePtr,
|
raw: SyntaxNodePtr,
|
||||||
_ty: PhantomData<N>,
|
_ty: PhantomData<N>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,18 +56,18 @@ impl<N: AstNode> Clone for AstPtr<N> {
|
||||||
impl<N: AstNode> AstPtr<N> {
|
impl<N: AstNode> AstPtr<N> {
|
||||||
pub fn new(node: &N) -> AstPtr<N> {
|
pub fn new(node: &N) -> AstPtr<N> {
|
||||||
AstPtr {
|
AstPtr {
|
||||||
ptr: SyntaxNodePtr::new(node.syntax()),
|
raw: SyntaxNodePtr::new(node.syntax()),
|
||||||
_ty: PhantomData,
|
_ty: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_node(self, source_file: &SourceFile) -> &N {
|
pub fn to_node(self, source_file: &SourceFile) -> &N {
|
||||||
let syntax_node = self.ptr.to_node(source_file);
|
let syntax_node = self.raw.to_node(source_file);
|
||||||
N::cast(syntax_node).unwrap()
|
N::cast(syntax_node).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn syntax_node_ptr(self) -> SyntaxNodePtr {
|
pub fn syntax_node_ptr(self) -> SyntaxNodePtr {
|
||||||
self.ptr
|
self.raw
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue