feat(varcon): Make all types hashable

This commit is contained in:
Ed Page 2020-05-27 20:47:49 -05:00
parent 94bc42eb07
commit 4ae8f91436
2 changed files with 9 additions and 9 deletions

View file

@ -2,7 +2,7 @@ mod parser;
pub use parser::ClusterIter; pub use parser::ClusterIter;
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Cluster { pub struct Cluster {
pub header: Option<String>, pub header: Option<String>,
pub entries: Vec<Entry>, pub entries: Vec<Entry>,
@ -17,7 +17,7 @@ impl Cluster {
} }
} }
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Entry { pub struct Entry {
pub variants: Vec<Variant>, pub variants: Vec<Variant>,
pub pos: Option<Pos>, pub pos: Option<Pos>,
@ -66,13 +66,13 @@ fn imply(variants: &mut Vec<Variant>, required: Category, missing: Category) {
} }
} }
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Variant { pub struct Variant {
pub types: Vec<Type>, pub types: Vec<Type>,
pub word: String, pub word: String,
} }
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Type { pub struct Type {
pub category: Category, pub category: Category,
pub tag: Option<Tag>, pub tag: Option<Tag>,
@ -89,7 +89,7 @@ pub enum Category {
Other, Other,
} }
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] #[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
pub enum Tag { pub enum Tag {
Eq, Eq,
Variant, Variant,

View file

@ -2,14 +2,14 @@ mod codegen;
pub use codegen::*; pub use codegen::*;
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Cluster { pub struct Cluster {
pub header: Option<&'static str>, pub header: Option<&'static str>,
pub entries: &'static [Entry], pub entries: &'static [Entry],
pub notes: &'static [&'static str], pub notes: &'static [&'static str],
} }
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Entry { pub struct Entry {
pub variants: &'static [Variant], pub variants: &'static [Variant],
pub pos: Option<Pos>, pub pos: Option<Pos>,
@ -19,13 +19,13 @@ pub struct Entry {
pub comment: Option<&'static str>, pub comment: Option<&'static str>,
} }
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Variant { pub struct Variant {
pub types: &'static [Type], pub types: &'static [Type],
pub word: &'static str, pub word: &'static str,
} }
#[derive(Clone, PartialEq, Eq, Debug)] #[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Type { pub struct Type {
pub category: Category, pub category: Category,
pub tag: Option<Tag>, pub tag: Option<Tag>,