Skip to content

附录/版本更新内容 翻译工作 #1134

Description

@EluvK

今天偶尔翻到附录里的版本更新内容,停更在了 1.62 ,前几天 rust 刚刚发布了 1.67

想借此机会多了解一下最新内容补充更多的知识水平,所以考虑翻译一下1.63-1.67这几次更新的内容。如果是已经完成了没有发出来麻烦告知我。

刚刚试着翻译了两段:


Rust 新版解读 | 1.63 | 重点: TODO!

Rust 1.63 官方 release doc: Announcing Rust 1.63.0 | Rust Blog

通过 rustup 安装的同学可以使用以下命令升级到 1.61 版本:

$ rustup update stable

范围线程 Scoped threads

Rust 从 1.0 版本起,就可以使用 std::thread::spawn 来创建一个线程,但是这个函数要求了其生成的线程必须拥有任何传递进去的参数的所有权,也就是说你不能把引用数据传递进去。在一些线程会在方法末尾退出的情况下(通常使用 join() 方法),这个严格的约束显得不必要,在此之前也通常使用 Arc 包裹数据的的方法来妥协。

随着 1.63 版本的推出,标准库新增了范围线程,允许在范围内创建使用当前调用栈内引用数据的线程。std::thread::scope 的API保证其中创建的线程会在自身返回前推出,也就允许安全的借用数据。看下面的例子,在 scope 内创建两个线程来,分别借用了数据:

let mut a = vec![1, 2, 3];
let mut x = 0;

std::thread::scope(|s| {
    s.spawn(|| {
        println!("hello from the first scoped thread");
        // 可以借用变量 `a`
        dbg!(&a);
    });
    s.spawn(|| {
        println!("hello from the second scoped thread");
        // 没有其它线程在使用,所以也可以可变借用 `x`
        x += a[0] + a[2];
    });
    println!("hello from the main thread");
});

// Scope 退出后,可以继续修改、访问变量。
a.push(4);
assert_eq!(x, a.len());

完成了 Non-lexical-lifetime 的生命周期检查器的迁移

1.63 的rustc,完全删除了之前的词法借用检查,完全启用了新的 NLL 借用检查器。这不会对编译结果有任何变化,但对编译器的借用检查有优化效果。

如果对NLL不了解,在本书 引用与借用 一章里有介绍。

或者看官方博客的介绍 NLL

更详细内容可以看原博客 blog


如果 @sunface @allandowney (看到前几次更新内容都是你发布的) 没有什么意见的话,我就斗胆接过这项工作,尽一份力了,后续完成后逐个发PR。

不过水平有限,也期待其它有兴趣的伙伴一起补充。

Activity

  1. Rustln commented on Feb 1, 2023

    @Rustln
    Contributor

    非常棒

  2. sunface commented on Feb 13, 2023

    @sunface
    Owner

    无敌~~以后就拜托兄弟了,之前的已经合并

  3. watonyweng commented on May 13, 2024

    @watonyweng
    Contributor

    @EluvK @sunface Hello, 1.78 is not visible on the side navigation in Rust Previous Version Updates, this link will prompt 404 when it is clicked.

    3827e619-03db-4441-856a-9c63f64b3eaf

  4. EluvK commented on May 13, 2024

    @EluvK
    ContributorAuthor

    @EluvK @sunface Hello, 1.78 is not visible on the side navigation in Rust Previous Version Updates, this link will prompt 404 when it is clicked.

    Deployment has not been triggered after #1419

    Maybe consider using github action to auto re-deployment after merge? @sunface

  5. watonyweng commented on May 13, 2024

    @watonyweng
    Contributor

    @EluvK @sunface Hello, 1.78 is not visible on the side navigation in Rust Previous Version Updates, this link will prompt 404 when it is clicked.

    Deployment has not been triggered after #1419

    Maybe consider using github action to auto re-deployment after merge? @sunface

    We can use this action,and i added this #1423.

  6. watonyweng commented on May 23, 2024

    @watonyweng
    Contributor

    @sunface @EluvK 目前的问题是执行 mdbook test 命令构建的 ci 无法跳过 .md 文件中的代码块,导致构建出错。

    img_v3_02b5_68b95d22-a8de-4d7b-b21a-618a8e6cbd9g

  7. EluvK commented on May 23, 2024

    @EluvK
    ContributorAuthor

    @sunface @EluvK 目前的问题是执行 mdbook test 命令构建的 ci 无法跳过 .md 文件中的代码块,导致构建出错。

    这个应该类似于 rust doc 里会尝试编译运行这些代码块吧?
    可以加上 ignore 忽略这个代码块不编译、no_run 仅检查编译但是不运行之类的标记。ref

    比如书里内容是演示编译报错或者展示部分代码块,就要加上 ignore 了。

    这个要做起来,工作量还挺大的。

  8. watonyweng commented on May 24, 2024

    @watonyweng
    Contributor

    @sunface @EluvK 目前的问题是执行 mdbook test 命令构建的 ci 无法跳过 .md 文件中的代码块,导致构建出错。

    这个应该类似于 rust doc 里会尝试编译运行这些代码块吧? 可以加上 ignore 忽略这个代码块不编译、no_run 仅检查编译但是不运行之类的标记。ref

    比如书里内容是演示编译报错或者展示部分代码块,就要加上 ignore 了。

    这个要做起来,工作量还挺大的。

    是的,我昨天已经验证过了,需要代码块添加ignore,mdbook-runnable ,我的具体操作如下:

    1. 批量查找 src 目录下包含 rust,并替换为 rust,ignore,mdbook-runnable
    2. 运行 mdbook test 命令,直到出现以下内容(个别代码块(运行结果)可能要添加 console)

    2469aaad-2bc1-47b3-b6b4-f2be7d64f8e3

    💚 稍后我会发起一个 #1426

  9. reopened this on Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions