在`Cargo.toml` 中定义的 `feature` 会被`Cargo` 通过命令行参数 `--cfg` 传给`rustc`,最终由后者完成编译:`rustc --cfg ...`。若项目中的代码想要测试 `feature` 是否存在,可以使用 [`cfg` 属性](https://doc.rust-lang.org/stable/reference/conditional-compilation.html#the-cfg-attribute)或[`cfg...
Update intro.md 85a5a27 sunfaceapproved these changesMar 16, 2024 View reviewed changes Owner sunfaceleft a comment sunfaceapproved these changesMar 16, 2024 View reviewed changes sunfacemerged commit07b6c8dintosunface:mainMar 16, 2024
通过例子学 Rust, Rust By Example 中文版,RBE 中文版,本书通过详细的可运行的 Rust 程序来讲解 Rust 语言有关的知识点,通俗易懂,是 Rust 初学者必备的学习参考书,同时也能作为 Rust 工程师日常工作中快速查找知识点的必备查询手册。
Macro core::cfg1.0.0· source· [−] macro_rules! cfg { ($($cfg:tt)*) => { ... }; } 在编译时评估配置标志的布尔组合。 除了#[cfg] 属性,还提供了此宏,以允许对配置标志进行布尔表达式评估。这通常会减少重复的代码。 该宏的语法与 cfg 属性的语法相同。 cfg! 与#[cfg] 不同,它不会删...
Heapless, `static` friendly data structures. Contribute to rust-embedded/heapless development by creating an account on GitHub.
Automatically emit rustc-check-cfg directives for AutoCfg #70 Merged cuviper merged 6 commits into cuviper:master from Techcable:feature/rustc-check-cfg Sep 27, 2024 +147 −11 Conversation 13 Commits 6 Checks 24 Files changed 6 Conversation Contributor Techcable commented Sep 10, 2024...
println!("cargo:rustc-check-cfg=cfg(no_relaxed_trait_bounds)"); @@ -25,7 +26,6 @@ fn main() { println!("cargo:rustc-check-cfg=cfg(no_std_atomic64)"); println!("cargo:rustc-check-cfg=cfg(no_systemtime_checked_add)"); println!("cargo:rustc-check-cfg=cfg(no_target_has_atom...
From 1.80 onwards, Rust will automatically check cfgs at compile time. This will particularly affect embassy-stm32, because it uses a lot of configs for conditional compilation based on the selected chip. This PR adds cargo:rustc-check-cfg instructions into build.rs, which attempt to cover al...
[build.rs] Emit cargo::rustc-check-cfg #1201 Closed joshlf opened this issue May 6, 2024· 0 comments · Fixed by #1204 Comments Member joshlf commented May 6, 2024 These directives permit us to remove the blanket #![allow(unexpected_cfgs)], which is a genuinely useful lint. ...
Problem: In Rust 1.80, cfg values other than Cargo feature flags must be communicated to Rust: Automatic checking of cfgs at compile-time. Without that, I believe we'll see warnings. Solution: I think we need build.rs files for every cra...