在当前(2025.4.7)最新已发布的rust编译器稳定版本内,如下哪个功能尚未支持: A trait upcast B async closure C let chain D…
- User
在当前(2025.4.7)最新已发布的rust编译器稳定版本内,如下哪个功能尚未支持: A trait upcast B async closure C let chain D inline const
Assistant
根据截至 2025 年 4 月 7 日的 Rust 编译器信息,我们可以分析各个功能的稳定性状态:
-
A. trait upcast (Trait 向上转型):
- 此功能允许将
dyn Trait类型的对象安全地转换为其超类型dyn SuperTrait。[[1]] - 根据搜索结果,
trait_upcasting功能已在 Rust 1.86.0(2025 年 4 月 3 日发布)中稳定 [26, 12, 11]。因此,该功能在当前的稳定版中是支持的。
- 此功能允许将
-
B. async closure (异步闭包):
- 异步闭包允许创建
async关键字修饰的闭包。[[2]] - 异步闭包已在 Rust 1.85.0(2025 年 2 月 20 日发布)中稳定 [2, 5, 19, 30]。因此,该功能在当前的稳定版中也是支持的。
- 异步闭包允许创建
-
C. let chain (let 链):
let链允许在if或while语句中串联多个let绑定和布尔表达式,例如if let Some(x) = foo() && let Some(y) = bar(x) && z > 0 { ... }。[[3]]- 此功能 (feature gate:
let_chains) 曾经计划在 Rust 2024 版中稳定 [9, 17]。虽然 Rust 2024 版已在 Rust 1.85.0 中稳定 [30],但let_chains功能本身尚未稳定 [20, 31, 6]。截至目前,它仍然是一个不稳定的特性,需要使用 nightly 编译器并启用#![feature(let_chains)]才能使用。
-
D. inline const (内联 const):
- 内联
const允许在需要值的地方(例如表达式、模式匹配、数组长度等)直接使用const { ... }块。 - 内联
const表达式(inline_constfeature)已在 Rust 1.79.0(2024 年 6 月发布)中稳定 [13, 22]。 内联const模式 (inline_const_pat) 仍然不稳定 [23]。但题目通常指表达式部分。
- 内联
结论:
在当前(2025 年 4 月 7 日)最新已发布的 Rust 稳定版本(应为 1.86.0 或更高)中:
- Trait upcast (A) 已稳定。[[4]]
- Async closure (B) 已稳定。
- Let chain (C) 尚未稳定。
- Inline const (D) (指表达式) 已稳定。[[5]][[6]]
因此,尚未支持的功能是 C. let chain。
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.