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
use std::fmt;
#[derive(Debug, PartialEq)]
pub enum VersionPart<'a> {
Number(i32),
Text(&'a str),
}
impl<'a> fmt::Display for VersionPart<'a> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
VersionPart::Number(n) => write!(f, "{}", n),
VersionPart::Text(t) => write!(f, "{}", t),
}
}
}
#[cfg_attr(tarpaulin, skip)]
#[cfg(test)]
mod tests {
use crate::version_part::VersionPart;
#[test]
fn display() {
assert_eq!(format!("{}", VersionPart::Number(123)), "123");
assert_eq!(format!("{}", VersionPart::Text("123")), "123");
}
}