Preparation for sharing

- rustfmt
- clippy
- comments
- README
This commit is contained in:
2023-05-25 19:14:24 +01:00
parent e99ade92ba
commit bc2714aad8
144 changed files with 3734 additions and 3243 deletions

View File

@@ -1,36 +1,35 @@
use std::fmt;
use crate::interner::{Token, InternedDisplay, Interner};
use crate::interner::{InternedDisplay, Interner, Tok};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RuleError {
Missing(Token<String>),
TypeMismatch(Token<String>),
Missing(Tok<String>),
TypeMismatch(Tok<String>),
/// Multiple occurences of a placeholder in a pattern are no longer
/// supported.
Multiple(Token<String>),
VecNeighbors(Token<String>, Token<String>),
Multiple(Tok<String>),
VecNeighbors(Tok<String>, Tok<String>),
}
impl InternedDisplay for RuleError {
fn fmt_i(&self, f: &mut fmt::Formatter<'_>, i: &Interner) -> fmt::Result {
match *self {
Self::Missing(key) => write!(f,
"Key {:?} not in match pattern",
i.r(key)
),
Self::TypeMismatch(key) => write!(f,
Self::Missing(key) =>
write!(f, "Key {:?} not in match pattern", i.r(key)),
Self::TypeMismatch(key) => write!(
f,
"Key {:?} used inconsistently with and without ellipsis",
i.r(key)
),
Self::Multiple(key) => write!(f,
"Key {:?} appears multiple times in match pattern",
i.r(key)
),
Self::VecNeighbors(left, right) => write!(f,
Self::Multiple(key) =>
write!(f, "Key {:?} appears multiple times in match pattern", i.r(key)),
Self::VecNeighbors(left, right) => write!(
f,
"Keys {:?} and {:?} are two vectorials right next to each other",
i.r(left), i.r(right)
)
i.r(left),
i.r(right)
),
}
}
}
}