mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-10 06:47:34 +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
@ -42,7 +42,7 @@ impl SyntaxNodePtr {
|
||||
/// Like `SyntaxNodePtr`, but remembers the type of node
|
||||
#[derive(Debug, PartialEq, Eq, Hash)]
|
||||
pub struct AstPtr<N: AstNode> {
|
||||
ptr: SyntaxNodePtr,
|
||||
raw: SyntaxNodePtr,
|
||||
_ty: PhantomData<N>,
|
||||
}
|
||||
|
||||
@ -56,18 +56,18 @@ impl<N: AstNode> Clone for AstPtr<N> {
|
||||
impl<N: AstNode> AstPtr<N> {
|
||||
pub fn new(node: &N) -> AstPtr<N> {
|
||||
AstPtr {
|
||||
ptr: SyntaxNodePtr::new(node.syntax()),
|
||||
raw: SyntaxNodePtr::new(node.syntax()),
|
||||
_ty: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
pub fn syntax_node_ptr(self) -> SyntaxNodePtr {
|
||||
self.ptr
|
||||
self.raw
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user