侧边栏壁纸
博主头像
龍啓博主等级

Vue development

  • 累计撰写 17 篇文章
  • 累计创建 17 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

Rust获取当前操作系统类型

龍啓
2022-09-25 / 0 评论 / 0 点赞 / 479 阅读 / 94 字
广告 广告
#[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");
}
0

评论区