mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Add empty bindings and some refactoring
This commit is contained in:
parent
9901f3e45e
commit
1446d620c5
2 changed files with 41 additions and 22 deletions
|
@ -99,13 +99,31 @@ pub(crate) struct Subtree {
|
|||
pub(crate) token_trees: Vec<TokenTree>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, Eq)]
|
||||
pub(crate) enum Separator {
|
||||
Literal(tt::Literal),
|
||||
Ident(tt::Ident),
|
||||
Puncts(SmallVec<[tt::Punct; 3]>),
|
||||
}
|
||||
|
||||
// Note that when we compare a Separator, we just care about its textual value.
|
||||
impl PartialEq for crate::Separator {
|
||||
fn eq(&self, other: &crate::Separator) -> bool {
|
||||
use crate::Separator::*;
|
||||
|
||||
match (self, other) {
|
||||
(Ident(ref a), Ident(ref b)) => a == b,
|
||||
(Literal(ref a), Literal(ref b)) => a == b,
|
||||
(Puncts(ref a), Puncts(ref b)) if a.len() == b.len() => {
|
||||
let a_iter = a.iter().map(|a| a.char);
|
||||
let b_iter = b.iter().map(|b| b.char);
|
||||
a_iter.eq(b_iter)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub(crate) struct Repeat {
|
||||
pub(crate) subtree: Subtree,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue