Rust编程语言入门之cargo、crates.io

[复制链接]
发表于 2023-4-9 22:20:36 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
cargo、crates.io

本章内容

一、通过 release profile 来自定义构建

release profile (发布配置


  • release profile:

    • 是预定义的
    • 可自定义:可使用不同的配置,对代码编译拥有更多的控制

  • 每个 profile 的配置都独立于其它的 profile
  • cargo 主要的两个 profile:

    • dev profile:适用于开发,cargo build
    • release profile:适用于发布,cargo build --release

自定义 profile


  • 针对每个 profile,Cargo 都提供了默认的配置
  • 如果想自定义 xxxx profile 的配置:

    • 可以在 Cargo.toml 里添加 [profile.xxxx] 区域,在里面覆盖默认配置的子集

  1. [package]
  2. name = "closure"
  3. version = "0.1.0"
  4. edition = "2021"
  5. # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
  6. [dependencies]
  7. [profile.dev]
  8. opt-level = 1
  9. [profile.release]
  10. opt-level = 3
复制代码
执行
[code]closure on  master [?] is
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!
继续阅读请点击广告
回复

使用道具 举报

×
登录参与点评抽奖,加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表