Merge pull request #891 from qwer252/main

pull/895/head
KaiserY 1 month ago committed by GitHub
commit b686761c69
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2,13 +2,13 @@ pub struct ThreadPool;
// ANCHOR: here
impl ThreadPool {
/// Create a new ThreadPool.
/// 创建一个新的线程池。
///
/// The size is the number of threads in the pool.
/// size 是池中线程的数量。
///
/// # Panics
///
/// The `new` function will panic if the size is zero.
/// 如果 size 为 0`new` 方法会 panic。
pub fn new(size: usize) -> ThreadPool {
assert!(size > 0);

@ -22,7 +22,7 @@ impl ThreadPool {
let mut threads = Vec::with_capacity(size);
for _ in 0..size {
// create some threads and store them in the vector
// 创建一些线程并将它们存入 vector 中。
}
ThreadPool { threads }

@ -111,6 +111,6 @@ fn main() {
此代码编译没有任何错误。注意 `r#` 前缀需同时用于函数名定义和 `main` 函数中的调用。
原始标识符允许使用你选择的任何单词作为标识符,即使该单词恰好是保留关键字。这给予了我们更大的自由来选择名字,这样与其他语言交互式就不用考虑到关键字问题,在要交互的语言中这个名字不是关键字。此外,原始标识符允许你使用以不同于你的 crate 使用的 Rust 版本编写的库。比如,`try` 在 2015 edition 中不是关键字,而在 2018、2021 和 2024 editio 则是。所以如果用 2015 edition 编写的库中带有 `try` 函数,在 2018 edition 中调用时就需要使用原始标识符语法,在这里是 `r#try`。有关版本的更多信息,请参见[附录 E][appendix-e]。
原始标识符允许使用你选择的任何单词作为标识符,即使该单词恰好是保留关键字。这给予了我们更大的自由来选择名字,这样与其他语言交互式就不用考虑到关键字问题,在要交互的语言中这个名字不是关键字。此外,原始标识符允许你使用以不同于你的 crate 使用的 Rust 版本编写的库。比如,`try` 在 2015 edition 中不是关键字,而在 2018、2021 和 2024 edition 则是。所以如果用 2015 edition 编写的库中带有 `try` 函数,在 2018 edition 中调用时就需要使用原始标识符语法,在这里是 `r#try`。有关版本的更多信息,请参见[附录 E][appendix-e]。
[appendix-e]: appendix-05-editions.html

Loading…
Cancel
Save