Why is `std::env::consts::OS` a string and not a rust enum?
⚓ Rust 📅 2025-11-30 👤 surdeus 👁️ 3I get that strings are more flexible, and in the case where a new os is released but does not exist in the enum, then it would be incompatible with a traditional enum, but can't it be something like this:
enum OperatingSystem {
Linux,
Windows,
MacOS,
Android,
IOS,
// ...
Other(String)
}
I get that the Other arm of the enum is very redundant, but I feel like making it an enum is just more developer friendly as well, as we get access to the pattern matching capabilities. I guess the only issue is the case where Other contains a value that may be related to the other known OSes.
1 post - 1 participant
🏷️ Rust_feed