Merge branch 'sunface:main' into main

pull/1248/head
Scott Rhodes 1 year ago committed by GitHub
commit b8230be586
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,6 +19,7 @@
## 教程简介 ## 教程简介
- 在线阅读: https://course.rs - 在线阅读: https://course.rs
- 离线阅读: course.pdf
**`Rust语言圣经`**涵盖从**入门到精通**所需的 Rust 知识,目录及内容都经过深思熟虑的设计,同时语言生动幽默,行文流畅自如,摆脱技术书籍常有的机器味和晦涩感。 **`Rust语言圣经`**涵盖从**入门到精通**所需的 Rust 知识,目录及内容都经过深思熟虑的设计,同时语言生动幽默,行文流畅自如,摆脱技术书籍常有的机器味和晦涩感。

@ -0,0 +1,34 @@
#! /bin/sh
###########################################################
# Description:
# This script write for mdbook project to generate pdf
###########################################################
cargo install mdbook mdbook-pdf
hasPdfSec=$(grep "output.pdf" ./book.toml)
if [ "$hasPdfSec" = "" ]; then
echo "===>>> Backup book.toml file..."
cp book.toml book.toml.bak
cat >> book.toml << EOF
[output.pdf]
scale = 1
paper-width = 10
paper-height = 12
margin-top = 1
margin-bottom = 1
margin-left = 1
EOF
fi
echo "===>>> Start build pdf..."
mdbook build
today=$(date +%Y%m%d)
echo "===>>> PDF rename to rust-curse-$today.pdf"
mv book/pdf/output.pdf rust-curse-"$today".pdf
if [ -f book.toml.bak ]; then
echo "===>>> Reverse book.toml file..."
mv book.toml.bak book.toml
fi
exit 0

@ -22,7 +22,7 @@ Rust 使用一个相对传统的语法来创建整数(`1``2`...)和浮
| 128 位 | `i128` | `u128` | | 128 位 | `i128` | `u128` |
| 视架构而定 | `isize` | `usize` | | 视架构而定 | `isize` | `usize` |
类型定义的形式统一为:`有无符号 + 类型大小(位数)`。**无符号数**表示数字只能取正数,而**有符号**则表示数字既可以取正数又可以取负数。就像在纸上写数字一样:当要强调符号时,数字前面可以带上正号或负号;然而,当很明显确定数字为正数时,就不需要加上正号了。有符号数字以[补码](https://en.wikipedia.org/wiki/Two%27s_complement)形式存储。 类型定义的形式统一为:`有无符号 + 类型大小(位数)`。**无符号数**表示数字只能取正数和0而**有符号**则表示数字可以取正数、负数还有0。就像在纸上写数字一样:当要强调符号时,数字前面可以带上正号或负号;然而,当很明显确定数字为正数时,就不需要加上正号了。有符号数字以[补码](https://en.wikipedia.org/wiki/Two%27s_complement)形式存储。
每个有符号类型规定的数字范围是 -(2<sup>n - 1</sup>) ~ 2<sup>n - 每个有符号类型规定的数字范围是 -(2<sup>n - 1</sup>) ~ 2<sup>n -
1</sup> - 1其中 `n` 是该定义形式的位长度。因此 `i8` 可存储数字范围是 -(2<sup>7</sup>) ~ 2<sup>7</sup> - 1即 -128 ~ 127。无符号类型可以存储的数字范围是 0 ~ 2<sup>n</sup> - 1所以 `u8` 能够存储的数字为 0 ~ 2<sup>8</sup> - 1即 0 ~ 255。 1</sup> - 1其中 `n` 是该定义形式的位长度。因此 `i8` 可存储数字范围是 -(2<sup>7</sup>) ~ 2<sup>7</sup> - 1即 -128 ~ 127。无符号类型可以存储的数字范围是 0 ~ 2<sup>n</sup> - 1所以 `u8` 能够存储的数字为 0 ~ 2<sup>8</sup> - 1即 0 ~ 255。

@ -44,7 +44,18 @@ ustc = { index = "https://mirrors.ustc.edu.cn/crates.io-index/" }
time = { registry = "ustc" } time = { registry = "ustc" }
``` ```
**在重新配置后,初次构建可能要较久的时间**,因为要下载更新 `ustc` 注册服务的索引文件,还挺大的... **在重新配置后,初次构建可能要较久的时间**,因为要下载更新 `ustc` 注册服务的索引文件,由于文件比较大,需要等待较长的时间。
此处有两点需要注意:
1. cargo 1.68 版本开始支持稀疏索引,不再需要完整克隆 crates.io-index 仓库,可以加快获取包的速度,如:
```toml
[source.ustc]
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"
```
2. cargo search 无法使用镜像
#### 科大镜像 #### 科大镜像
上面使用的是科大提供的注册服务,也是 Rust 最早期的注册服务,感谢大大们的贡献。除此之外,大家还可以选择下面的镜像服务: 上面使用的是科大提供的注册服务,也是 Rust 最早期的注册服务,感谢大大们的贡献。除此之外,大家还可以选择下面的镜像服务:
@ -60,6 +71,10 @@ replace-with = 'rsproxy'
[source.rsproxy] [source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index" registry = "https://rsproxy.cn/crates.io-index"
# 稀疏索引,要求 cargo >= 1.68
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy] [registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index" index = "https://rsproxy.cn/crates.io-index"

Loading…
Cancel
Save