28 ParseError(ParseError),
29 #[error("[Preprocessor Error] {0}")]
30 PreprocessorError(PreprocessorError),
31 #[error("[Runtime Error] {0}")] 32 RuntimeError(RuntimeError), 33 #[error("[Runner Error] {0}")]
34 RunnerError(RunnerError),
35 #[error("[Typecheck Error] {0}")]
24pub enum Error {
25 #[error("[Compile Error] {0}")]
26 CompileError(CompileError),
27 #[error("[Parse Error] {0}")] 28 ParseError(ParseError), 29 #[error("[Preprocessor Error] {0}")]
30 PreprocessorError(PreprocessorError),
31 #[error("[Runtime Error] {0}")]
82pub enum CompileError {
83 #[error("Nasm failed t: {0}")]
84 NasmInvokeError(std::io::Error),
85 #[error("Nasm compile error")] 86 NasmCompileError, 87 #[error("Nasm invoke error: {0}")]
88 LdInvokeError(std::io::Error),
89 #[error("Ld linker error")]
34 RunnerError(RunnerError),
35 #[error("[Typecheck Error] {0}")]
36 TypecheckError(TypecheckError),
37 #[error("[IO Error] {0}")] 38 IOError(IOError), 39}
40
41#[derive(Error, Debug)]
32 RuntimeError(RuntimeError),
33 #[error("[Runner Error] {0}")]
34 RunnerError(RunnerError),
35 #[error("[Typecheck Error] {0}")] 36 TypecheckError(TypecheckError), 37 #[error("[IO Error] {0}")]
38 IOError(IOError),
39}
Enumeration variants with the same prefix or suffix as the enumeration name are repetitive. Variants should describe themselves, and not include the name of the parent enum in their names.
Restrict the names of enumeration variants to avoid repetition. Repetitive names encourage glob exports which may cause namespace overlaps.
enum Brush {
LineBrush,
CircleBrush,
SelectBrush
}
// this nomenclature encourages glob exports:
use Brush::*;
let x = LineBrush;
match x {
LineBrush => { }
CircleBrush => { }
_ => { }
}
enum Brush {
Line,
Circle,
Select
}
// equally explicit, but more idiomatic:
let x = Brush::Line;
match x {
Brush::Line => { }
Brush::Circle => { }
_ => { }
}