Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Rust 1.95(2026-04)

官方发布说明:Announcing Rust 1.95.0

cfg_select! 宏把平台条件选择表达成编译期分支,可替代许多简单的 cfg-if 使用场景:

#![allow(unused)]
fn main() {
cfg_select! {
    unix => { fn platform() { println!("unix"); } }
    _ => { fn platform() { println!("other"); } }
}
}

match 表达式支持 if let guard,可以在匹配分支中继续解构并检查 Result。另外,稳定编译器不再接受自定义 target specification;需要构建自定义目标的工具链应固定在 nightly 并在 CI 中单独验证。