#[cfg(target_os = "macos")]
static DEFAULT_PATH: &str = "macos";
#[cfg(target_os = "linux")]
static DEFAULT_PATH: &str = "linux";
#[cfg(target_os = "windows")]
static DEFAULT_PATH: &str = "windows";
还可以使用cfg!语法扩展名
if cfg!(target_os = "windows") {
println!("this is windows");
} else if cfg!(target_os = "macos") {
println!("this is macos");
} else if cfg!(target_os = "linux") {
println!("this is linux");
}