#[non_exhaustive]pub enum RuleError {
UnknownKind {
name: String,
},
DuplicateNode {
name: String,
},
IndentTooWide {
columns: u8,
},
SeparatorIsDelimiter {
node: String,
},
TrailingNeedsDelimiters {
node: String,
},
}Expand description
Why Rules::compile refused a set of rules.
Every variant names the offending kind, so the message can point at the right line of a sketch.
§Examples
use fmt_lang::{NodeRule, RuleError, Rules};
let err = Rules::new().node(NodeRule::new("objekt")).compile(|_| None::<u8>).unwrap_err();
assert_eq!(err, RuleError::UnknownKind { name: "objekt".into() });Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnknownKind
A rule names a kind the language does not have. Fix the spelling, or
mark the rule optional if it comes from
a preset meant for several languages.
DuplicateNode
Two node rules name the same kind. Merge them into one rule.
IndentTooWide
The indentation step is wider than
MAX_INDENT_STEP columns.
SeparatorIsDelimiter
A node’s separator is also one of its delimiters, so the formatter cannot tell the two roles apart. Use distinct kinds.
TrailingNeedsDelimiters
A node rule sets a trailing-separator policy other than
Trailing::Preserve but no delimiters.
The policy needs the closing delimiter to know where the list ends;
add delimiters or keep Preserve.
Trait Implementations§
impl Eq for RuleError
Source§impl Error for RuleError
impl Error for RuleError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()