rust-lang-cn / book-cn Goto Github PK
View Code? Open in Web Editor NEWRust 程序设计语言 中文版——Chinese translation of The Rust Programming Language (Book)
Home Page: https://rustwiki.org/zh-CN/book
License: Apache License 2.0
Rust 程序设计语言 中文版——Chinese translation of The Rust Programming Language (Book)
Home Page: https://rustwiki.org/zh-CN/book
License: Apache License 2.0
Hi all
Here is that book converted into epub.
As I can see there are many pages still in English.
Zip archive with book is here:
https://github.com/blandger/book-cn/releases/tag/0.0.1
Here is another repo with book in epub.
https://github.com/blandger/trpl-zh-cn/releases/tag/v.0.0.1
ch19-04 动态大小类型和Sized
trait 第四行
因为直到运行时都不能知道大其小
语序有点小问题
https://rustwiki.org/zh-CN/book/ch04-02-references-and-borrowing.html
这个限制的好处是 Rust 可以在编译时就避免数据竞争。数据竞争(data race)类似于竞态条件,它可由这三个行为造成:
两个或更多指针同时访问同一数据。
至少有一个指针被用来写入数据。
没有同步数据访问的机制。
这三个行为同时发生才会造成data race,而不是单一行为。
在 https://rustwiki.org/zh-CN/book/ch03-02-data-types.html 这里有一个拼写重复问题。
第三章 第二小节 data type 31 行
原文:
整数(integer)是没有是没有小数部分的数字
不知道是否是重复出现了相同的词语呢?
闭包:可以捕获环境的匿名函数 第一段代码展开来,可以看到代码都包含在了main方法中。
Closures: Anonymous Functions that Can Capture Their Environment 英文版,第一段展开,可以看到main方法是分离的
如果使用 None 而不是 Some,需要告诉 Rust Option 是什么类型的,因为编译器只通过 None 值无法推断出 Some 成员保存的值的类型。
应该改为:
如果使用 None 而不是 Some,需要告诉 Rust Option 是什么类型的,因为编译器只通过 None 值无法推断出 None 成员保存的值的类型。
当前示例相比原文档,有部分内容需要同步一下。
个人出现了点问题,无法补充图片展示,需要更新的地方是 示例 7-3 与 示例 7-6 报错信息(位于 ch07-03)
或许说,这种同步工作,通常定在某一周期,进行整体更新会更合。因此我只说出该差别的存在,并没有动手修改。
谢谢你们为翻译文档所做的工作 💯 . 我在阅读的时候似乎发现了一点小问题:
第三章第一节 variables-and-mutability 124 行
原句:
所以变量隐藏可以我们就不必提出不同的名称
这里感觉语义不通顺,是否可以考虑改成
所以隐藏变量我们就可以不必提出不同的名称
第19章章节为
19. 高级特征
19.1. 不安全的 Rust
19.2. 高级 trait
19.3. 高级类型
19.4. 高级函数与闭包
19.5. 宏
其小章节19.2 ~ 19.5应对应源文件ch19-02 ~ ch19-05,实际对应到源文件ch19-03~ch19-06
猜数游戏
0.9.0成了0.6.0
中文:如果要使用 rand 版本 0.9.0 或 0.9.x 系列中的任何版本,则必须像这样更新 Cargo.toml 文件:
[dependencies]
----rand = "0.6.0"----
下一次运行 cargo build 时,Cargo 会从 registry 更新可用的 crate,并根据你指定的新版本重新计算。
英文:If you wanted to use rand version 0.9.0 or any version in the 0.9.x series, you’d have to update the Cargo.toml file to look like this instead:
[dependencies]
----rand = "0.9.0"----
The next time you run cargo build, Cargo will update the registry of crates available and reevaluate your rand requirements according to the new version you have specified.
感觉有写句子读起来不是中文的语序,有点怪怪的
比如
示例 4-5 中的元组代码有这样一个问题:我们必须将 String 返回给调用函数,以便在调用 calculate_length 后仍能使用 String,因为 String 被移动到了 calculate_length 内。
这个句子应该把因为移到前面去,不然读起来很怪
还有
下面是如何定义并使用一个(新的)calculate_length 函数,它以一个对象的引用作为参数而不是获取值的所有权:
文件名: src/main.rs
fn main() {
let s1 = String::from("hello");
let len = calculate_length(&s1);
println!("The length of '{}' is {}.", s1, len);
}
fn calculate_length(s: &String) -> usize {
s.len()
}
那一句话下面就是代码了,可以直接把”如何定义并使用“删去,要不然感觉很奇怪
原文:
The #[macro_export] annotation indicates that this macro should be made available whenever the crate in which the macro is defined is brought into scope.
目前的翻译:
无论何时导入定义了宏的包,#[macro_export] 标注说明宏应该是可用的。
建议的翻译:
#[macro_export] 标注说明,只要将定义了宏的crate引入作用域,宏就应当是可用的。
首先,这里翻译的语序不准确,至少影响理解。说实话只看翻译文本我完全不理解这句话是什么意思。
第二,crate不应该被翻译成“包”。这里应当区分crate
和package
。
第三,应该保留"导入作用域",因为下一句话:
Without this annotation, the macro can’t be brought into scope.
指“如果没有该标注,这个宏不能(随着crate一起)被引入作用域。”
如果去掉“引入作用域”会影响对下一句话的理解。
如题
显示是空白的,切换英文版正常。
https://rustwiki.org/zh-CN/book/ch03-05-control-flow.html
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.