aboutsummaryrefslogtreecommitdiff
path: root/src/yellow/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/yellow/mod.rs')
-rw-r--r--src/yellow/mod.rs31
1 files changed, 0 insertions, 31 deletions
diff --git a/src/yellow/mod.rs b/src/yellow/mod.rs
index 9a6203cc1..4fd0d24d7 100644
--- a/src/yellow/mod.rs
+++ b/src/yellow/mod.rs
@@ -3,10 +3,6 @@ mod red;
3mod syntax; 3mod syntax;
4mod builder; 4mod builder;
5 5
6use std::{
7 sync::{Arc, Weak},
8 mem
9};
10pub(crate) use self::{ 6pub(crate) use self::{
11 green::{GreenNode, GreenNodeBuilder}, 7 green::{GreenNode, GreenNodeBuilder},
12 red::RedNode, 8 red::RedNode,
@@ -14,30 +10,3 @@ pub(crate) use self::{
14 builder::GreenBuilder, 10 builder::GreenBuilder,
15}; 11};
16pub use self::syntax::SyntaxNode; 12pub use self::syntax::SyntaxNode;
17
18// This could be just `*const T`, but we use `Weak` for additional checks
19#[derive(Debug)]
20pub(crate) struct Ptr<T>(Weak<T>);
21
22impl<T> Clone for Ptr<T> {
23 fn clone(&self) -> Self {
24 Ptr(self.0.clone())
25 }
26}
27
28impl<T> Ptr<T> {
29 fn clone(self_: &Ptr<T>) -> Ptr<T> {
30 Ptr(Weak::clone(&self_.0))
31 }
32
33 fn new(arc: &Arc<T>) -> Ptr<T> {
34 Ptr(Arc::downgrade(arc))
35 }
36
37 unsafe fn get(&self) -> &T {
38 let t = self.0.upgrade()
39 .expect("caller must guarantee that Ptr is not null");
40 let t: &T = &*t;
41 mem::transmute(t)
42 }
43}