Posted in

Rust 1.80 添加延迟类型_AI阅读总结 — 包阅AI

包阅导读总结

1.

关键词:Rust 1.80、lazy types、programming language、update、initialization

2.

总结:Rust 1.80 已发布,新增“lazy”类型,可延迟数据初始化直至首次访问。7 月 25 日推出,旧版本可通过命令更新。新的 LazyCell 和 LazyLock 类似之前版本,前者缺乏线程同步。

3.

主要内容:

– Rust 1.80 发布

– 是流行的内存安全编程语言的最新版本

– 新特性

– 新增“lazy”类型,包括 LazyCell 和 LazyLock

– 延迟数据初始化直至首次访问

– 发布时间

– 7 月 25 日推出

– 更新方式

– 安装过旧版本的开发者可通过运行特定命令更新

– 与之前类型对比

– 与 Rust 1.70 中的 OnceCell 和 OnceLock 类似

– 初始化函数包含在 cell 中

– LazyLock 是线程安全的,LazyCell 缺乏线程同步但可用于 thread_local statics

思维导图:

文章地址:https://www.infoworld.com/article/3477620/rust-1-80-adds-lazy-types.html

文章来源:infoworld.com

作者:InfoWorld

发布时间:2024/7/25 19:38

语言:英文

总字数:325字

预计阅读时间:2分钟

评分:91分

标签:Rust,编程语言,延迟初始化,内存管理,软件开发


以下为原文内容

本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com

Rust 1.80, the latest version of the popular memory-safe programming language, has been released, featuring “lazy” types to delay initialization of data until their first access.

Rust 1.80 was unveiled on July 25. Developers with a previous version of Rust installed via rustup can update to version 1.80 by running $ rustup update stable.

The new lazy types LazyCell and LazyLock, which delay initialization of values until first access, are similar to the OnceCell and OnceLock types stabilized in Rust 1.70, but with the initialization function included in the cell. This completes the stabilization of functionality adopted into the standard library from lazy_static and once_cell crates. LazyLock is the thread-safe option, suitable for places like static values. LazyCell lacks thread synchronization, so does not implement Sync, which is needed for static, but can still be used in thread_local! statics, the Rust team said.