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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#![deny(missing_docs)]
pub const OPENGL: &'static str = "OpenGL";
pub const VULKAN: &'static str = "Vulkan";
pub const DIRECTX: &'static str = "DirectX";
pub const METAL: &'static str = "Metal";
use std::borrow::Cow;
#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
pub struct Version {
pub api: Cow<'static, str>,
pub major: u32,
pub minor: u32,
}
impl Version {
pub fn opengl(major: u32, minor: u32) -> Version {
Version {
api: OPENGL.into(),
major,
minor,
}
}
pub fn vulkan(major: u32, minor: u32) -> Version {
Version {
api: VULKAN.into(),
major,
minor,
}
}
pub fn directx(major: u32, minor: u32) -> Version {
Version {
api: DIRECTX.into(),
major,
minor,
}
}
pub fn metal(major: u32, minor: u32) -> Version {
Version {
api: METAL.into(),
major,
minor,
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_it() {
let a = Version::opengl(3, 2);
let b = Version::opengl(4, 0);
assert!(b > a);
}
}