diff options
author | Seivan Heidari <[email protected]> | 2019-11-14 22:20:27 +0000 |
---|---|---|
committer | Seivan Heidari <[email protected]> | 2019-11-14 22:20:27 +0000 |
commit | c622413bc72ea56d5f62a16788d897cb61eca948 (patch) | |
tree | 9de3dbe8b5c935ed168efac4e70770e54fbe0714 /crates/ra_hir_expand/src/lib.rs | |
parent | 0525778a3ad590492b51cc11085d815f9bb8f92b (diff) | |
parent | bbb022d3999b3038549ec6c309efb065231c896a (diff) |
Merge branch 'master' of https://github.com/rust-analyzer/rust-analyzer into feature/themes
Diffstat (limited to 'crates/ra_hir_expand/src/lib.rs')
-rw-r--r-- | crates/ra_hir_expand/src/lib.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/ra_hir_expand/src/lib.rs b/crates/ra_hir_expand/src/lib.rs index c6ffa2c6f..930789b0f 100644 --- a/crates/ra_hir_expand/src/lib.rs +++ b/crates/ra_hir_expand/src/lib.rs | |||
@@ -223,7 +223,7 @@ impl<N: AstNode> AstId<N> { | |||
223 | } | 223 | } |
224 | } | 224 | } |
225 | 225 | ||
226 | #[derive(Debug, PartialEq, Eq, Clone, Copy)] | 226 | #[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)] |
227 | pub struct Source<T> { | 227 | pub struct Source<T> { |
228 | pub file_id: HirFileId, | 228 | pub file_id: HirFileId, |
229 | pub ast: T, | 229 | pub ast: T, |
@@ -233,6 +233,9 @@ impl<T> Source<T> { | |||
233 | pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> { | 233 | pub fn map<F: FnOnce(T) -> U, U>(self, f: F) -> Source<U> { |
234 | Source { file_id: self.file_id, ast: f(self.ast) } | 234 | Source { file_id: self.file_id, ast: f(self.ast) } |
235 | } | 235 | } |
236 | pub fn as_ref(&self) -> Source<&T> { | ||
237 | Source { file_id: self.file_id, ast: &self.ast } | ||
238 | } | ||
236 | pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode { | 239 | pub fn file_syntax(&self, db: &impl db::AstDatabase) -> SyntaxNode { |
237 | db.parse_or_expand(self.file_id).expect("source created from invalid file") | 240 | db.parse_or_expand(self.file_id).expect("source created from invalid file") |
238 | } | 241 | } |