diff options
author | Aleksey Kladov <[email protected]> | 2018-08-13 12:24:22 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-13 12:24:22 +0100 |
commit | ed2ac1713326df6b926062efcc6109a20cdf7c37 (patch) | |
tree | c1c75d09e2adbbd54190c5b6ce6efdb7ea251da3 /crates/libsyntax2/src/yellow/green.rs | |
parent | 18486a02fae5966e61f16ea7bc5c33c6c7c69487 (diff) |
smol_str to a crate
Diffstat (limited to 'crates/libsyntax2/src/yellow/green.rs')
-rw-r--r-- | crates/libsyntax2/src/yellow/green.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/crates/libsyntax2/src/yellow/green.rs b/crates/libsyntax2/src/yellow/green.rs index f505b26d7..700f2704f 100644 --- a/crates/libsyntax2/src/yellow/green.rs +++ b/crates/libsyntax2/src/yellow/green.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | use { | 2 | |
3 | SyntaxKind, TextUnit, | 3 | use smol_str::SmolStr; |
4 | smol_str::SmolStr, | 4 | |
5 | }; | 5 | use {SyntaxKind, TextUnit}; |
6 | 6 | ||
7 | #[derive(Clone, Debug)] | 7 | #[derive(Clone, Debug)] |
8 | pub(crate) enum GreenNode { | 8 | pub(crate) enum GreenNode { |
@@ -31,7 +31,7 @@ impl GreenNode { | |||
31 | 31 | ||
32 | pub fn text_len(&self) -> TextUnit { | 32 | pub fn text_len(&self) -> TextUnit { |
33 | match self { | 33 | match self { |
34 | GreenNode::Leaf { text, ..} => TextUnit::of_str(text.as_str()), | 34 | GreenNode::Leaf { text, .. } => TextUnit::of_str(text.as_str()), |
35 | GreenNode::Branch(b) => b.text_len(), | 35 | GreenNode::Branch(b) => b.text_len(), |
36 | } | 36 | } |
37 | } | 37 | } |
@@ -54,6 +54,13 @@ impl GreenNode { | |||
54 | } | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
57 | |||
58 | pub fn leaf_text(&self) -> Option<SmolStr> { | ||
59 | match self { | ||
60 | GreenNode::Leaf { text, .. } => Some(text.clone()), | ||
61 | GreenNode::Branch(_) => None, | ||
62 | } | ||
63 | } | ||
57 | } | 64 | } |
58 | 65 | ||
59 | #[derive(Clone, Debug)] | 66 | #[derive(Clone, Debug)] |