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
mod os_name;
mod arch;
mod environment;
use crate::os_name::ret_os_name;
use crate::arch::ret_arch;
use crate::environment::ret_environment;
#[derive(Debug)]
pub struct Desktop {
os_name: &'static str,
arch: &'static str,
environment: &'static str,
}
impl Desktop {
pub fn get() -> Self {
Desktop {
os_name: ret_os_name(),
arch: ret_arch(),
environment: ret_environment(),
}
}
pub fn os_name(&self) -> &'static str {
self.os_name
}
pub fn arch(&self) -> &'static str {
self.arch
}
pub fn environment(&self) -> &'static str {
self.environment
}
}
#[test]
fn test_struct() {
let d = Desktop::get();
println!("{:#?}", d);
}