Derive Hash for TokenTrees

This commit is contained in:
Edwin Cheng 2019-11-28 13:41:58 +08:00
parent 484acc8a61
commit 89fbd0db02

View file

@ -33,14 +33,14 @@ impl TokenId {
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TokenTree {
Leaf(Leaf),
Subtree(Subtree),
}
impl_froms!(TokenTree: Leaf, Subtree);
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Leaf {
Literal(Literal),
Punct(Punct),
@ -48,13 +48,13 @@ pub enum Leaf {
}
impl_froms!(Leaf: Literal, Punct, Ident);
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Subtree {
pub delimiter: Delimiter,
pub token_trees: Vec<TokenTree>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Delimiter {
Parenthesis,
Brace,
@ -62,24 +62,24 @@ pub enum Delimiter {
None,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Literal {
pub text: SmolStr,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Punct {
pub char: char,
pub spacing: Spacing,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum Spacing {
Alone,
Joint,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Ident {
pub text: SmolStr,
pub id: TokenId,