1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use std::fmt;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Field {
Chromosome,
Position,
Ids,
ReferenceBases,
AlternateBases,
QualityScore,
Filters,
Info,
Format,
}
impl AsRef<str> for Field {
fn as_ref(&self) -> &str {
match self {
Self::Chromosome => "CHROM",
Self::Position => "POS",
Self::Ids => "ID",
Self::ReferenceBases => "REF",
Self::AlternateBases => "ALT",
Self::QualityScore => "QUAL",
Self::Filters => "FILTER",
Self::Info => "INFO",
Self::Format => "FORMAT",
}
}
}
impl fmt::Display for Field {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(self.as_ref())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_fmt() {
assert_eq!(Field::Chromosome.to_string(), "CHROM");
assert_eq!(Field::Position.to_string(), "POS");
assert_eq!(Field::Ids.to_string(), "ID");
assert_eq!(Field::ReferenceBases.to_string(), "REF");
assert_eq!(Field::AlternateBases.to_string(), "ALT");
assert_eq!(Field::QualityScore.to_string(), "QUAL");
assert_eq!(Field::Filters.to_string(), "FILTER");
assert_eq!(Field::Info.to_string(), "INFO");
assert_eq!(Field::Format.to_string(), "FORMAT");
}
}