This commit is contained in:
sunface 2022-03-07 13:10:14 +08:00
commit c4230eb4fe
3 changed files with 6 additions and 5 deletions

View File

@ -18,7 +18,7 @@ Although they are so awesome, we have our own secret weapons :)
- Besides examples, we have `a lot of exercises`, you can Read, Edit and Run them ONLINE
- Covering nearly all aspects of Rust, such as async/await, threads, sync primitives, optimizing and standard libraries** etc.
- Covering nearly all aspects of Rust, such as async/await, threads, sync primitives, optimizing and standard libraries etc.
- Every exercise has its own solutions

View File

@ -40,7 +40,7 @@ fn main() {
assert_eq!("u32".to_string(), type_of(&x));
}
// 以下还输可以获取传入参数的类型,并返回类型的字符串形式,例如 "i8", "u8", "i32", "u32"
// 以下函数可以获取传入参数的类型,并返回类型的字符串形式,例如 "i8", "u8", "i32", "u32"
fn type_of<T>(_: &T) -> String {
format!("{}", std::any::type_name::<T>())
}
@ -142,6 +142,7 @@ fn main() {
// 整数减法
assert!(1i32 - 2 == __);
assert!(1u8 - 2 == -1);
assert!(3 * 50 == __);
assert!(9.6 / 3.2 == 3.0); // error ! 修改它让代码工作
@ -162,4 +163,4 @@ fn main() {
}
```
> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下)
> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下)

View File

@ -108,7 +108,7 @@ fn main() {
```
#### 可变性
8. 🌟 错误: 从可不用对象借用可用
8. 🌟 错误: 从不可变对象借用可变
```rust,editable
fn main() {
@ -167,4 +167,4 @@ fn main() {
}
```
> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下)
> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下)