Skip to content

Commit 3157dfd

Browse files
author
Steve Lee (POWERSHELL HE/HIM) (from Dev Box)
committed
implement Display so casing for macOS is correct
1 parent 520592b commit 3157dfd

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

osinfo/src/config.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
use serde::Serialize;
5+
use std::fmt::Display;
56
use std::string::ToString;
67

78
/// Returns information about the operating system.
@@ -48,6 +49,16 @@ pub enum Family {
4849
Windows,
4950
}
5051

52+
impl Display for Family {
53+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
54+
match self {
55+
Family::Linux => write!(f, "Linux"),
56+
Family::MacOS => write!(f, "macOS"),
57+
Family::Windows => write!(f, "Windows"),
58+
}
59+
}
60+
}
61+
5162
const ID: &str = "https://developer.microsoft.com/json-schemas/dsc/os_info/20230303/Microsoft.Dsc.OS_Info.schema.json";
5263

5364
impl OsInfo {
@@ -69,7 +80,7 @@ impl OsInfo {
6980
let version = os_info.version().to_string();
7081
let name = Some(
7182
match &architecture {
72-
Some(arch) => format!("{family:?} {version} {arch}"),
83+
Some(arch) => format!("{family} {version} {arch}"),
7384
None => format!("{family:?} {version}"),
7485
}
7586
);

0 commit comments

Comments
 (0)