To get the type of the system in Rust, we can use the std::env::consts::OS constant, which returns a string representing the operating system family the program is running on. Here is an example code snippet:
main.rs96 chars5 linesThe std::env::consts module provides other useful constants such as ARCH, DLL_EXTENSION, EXE_EXTENSION, FAMILY, OS_FAMILY, PATH_SEPARATOR, POINTER_WIDTH, and STATIC_LIBRARY_EXTENSION that we can use to get more specifics about the system.
gistlibby LogSnag