aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/yellow/green.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-08-13 12:24:22 +0100
committerAleksey Kladov <[email protected]>2018-08-13 12:24:22 +0100
commited2ac1713326df6b926062efcc6109a20cdf7c37 (patch)
treec1c75d09e2adbbd54190c5b6ce6efdb7ea251da3 /crates/libsyntax2/src/yellow/green.rs
parent18486a02fae5966e61f16ea7bc5c33c6c7c69487 (diff)
smol_str to a crate
Diffstat (limited to 'crates/libsyntax2/src/yellow/green.rs')
-rw-r--r--crates/libsyntax2/src/yellow/green.rs17
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 @@
1use std::sync::Arc; 1use std::sync::Arc;
2use { 2
3 SyntaxKind, TextUnit, 3use smol_str::SmolStr;
4 smol_str::SmolStr, 4
5}; 5use {SyntaxKind, TextUnit};
6 6
7#[derive(Clone, Debug)] 7#[derive(Clone, Debug)]
8pub(crate) enum GreenNode { 8pub(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)]