1use std::fmt;
2
3#[derive(Debug, PartialEq, Clone, Copy)]
4pub enum Mnemonic {
5 General,
8 Miscellaneous,
10 ProgramNumber,
12 ToolChange,
14 Subroutine,
16}
17
18pub static G: Mnemonic = Mnemonic::General;
19pub static M: Mnemonic = Mnemonic::Miscellaneous;
20pub static P: Mnemonic = Mnemonic::ProgramNumber;
21pub static T: Mnemonic = Mnemonic::ToolChange;
22pub static O: Mnemonic = Mnemonic::Subroutine;
23
24impl fmt::Display for Mnemonic {
25 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
26 use Mnemonic::*;
27
28 let mnemonic_char = match self {
29 General => 'G',
30 Miscellaneous => 'M',
31 ProgramNumber => 'P',
32 ToolChange => 'T',
33 Subroutine => 'O',
34 };
35
36 write!(f, "{}", mnemonic_char)
37 }
38}