aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_mbe/src/lib.rs')
-rw-r--r--crates/ra_mbe/src/lib.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/crates/ra_mbe/src/lib.rs b/crates/ra_mbe/src/lib.rs
index be9ea3ebb..08bb89a6a 100644
--- a/crates/ra_mbe/src/lib.rs
+++ b/crates/ra_mbe/src/lib.rs
@@ -99,13 +99,31 @@ pub(crate) struct Subtree {
99 pub(crate) token_trees: Vec<TokenTree>, 99 pub(crate) token_trees: Vec<TokenTree>,
100} 100}
101 101
102#[derive(Clone, Debug, PartialEq, Eq)] 102#[derive(Clone, Debug, Eq)]
103pub(crate) enum Separator { 103pub(crate) enum Separator {
104 Literal(tt::Literal), 104 Literal(tt::Literal),
105 Ident(tt::Ident), 105 Ident(tt::Ident),
106 Puncts(SmallVec<[tt::Punct; 3]>), 106 Puncts(SmallVec<[tt::Punct; 3]>),
107} 107}
108 108
109// Note that when we compare a Separator, we just care about its textual value.
110impl PartialEq for crate::Separator {
111 fn eq(&self, other: &crate::Separator) -> bool {
112 use crate::Separator::*;
113
114 match (self, other) {
115 (Ident(ref a), Ident(ref b)) => a == b,
116 (Literal(ref a), Literal(ref b)) => a == b,
117 (Puncts(ref a), Puncts(ref b)) if a.len() == b.len() => {
118 let a_iter = a.iter().map(|a| a.char);
119 let b_iter = b.iter().map(|b| b.char);
120 a_iter.eq(b_iter)
121 }
122 _ => false,
123 }
124 }
125}
126
109#[derive(Clone, Debug, PartialEq, Eq)] 127#[derive(Clone, Debug, PartialEq, Eq)]
110pub(crate) struct Repeat { 128pub(crate) struct Repeat {
111 pub(crate) subtree: Subtree, 129 pub(crate) subtree: Subtree,