From 258f0ed5899ac003a677647a9e8dc30a57ab1628 Mon Sep 17 00:00:00 2001 From: sunface Date: Tue, 1 Mar 2022 22:06:38 +0800 Subject: [PATCH] add solutions for variables --- src/basic-types/char-bool-unit.md | 4 +++- src/basic-types/functions.md | 4 +++- src/basic-types/numbers.md | 2 ++ src/basic-types/statements-expressions.md | 4 +++- src/compound-types/array.md | 1 + src/compound-types/enum.md | 6 ++++-- src/compound-types/slice.md | 2 ++ src/compound-types/string.md | 3 +-- src/compound-types/struct.md | 4 +++- src/compound-types/tuple.md | 2 ++ src/flow-control.md | 4 +++- src/ownership/borrowing.md | 4 +++- src/ownership/ownership.md | 3 +++ src/pattern-match/match-iflet.md | 3 +++ src/pattern-match/patterns.md | 4 +++- src/variables.md | 5 ++++- zh-CN/src/basic-types/char-bool-unit.md | 4 +++- zh-CN/src/basic-types/functions.md | 4 +++- zh-CN/src/basic-types/numbers.md | 2 ++ zh-CN/src/basic-types/statements-expressions.md | 4 +++- zh-CN/src/compound-types/array.md | 1 + zh-CN/src/compound-types/enum.md | 4 +++- zh-CN/src/compound-types/slice.md | 2 ++ zh-CN/src/compound-types/string.md | 2 +- zh-CN/src/compound-types/struct.md | 4 +++- zh-CN/src/compound-types/tuple.md | 3 +++ zh-CN/src/flow-control.md | 4 +++- zh-CN/src/ownership/borrowing.md | 4 +++- zh-CN/src/ownership/ownership.md | 4 +++- zh-CN/src/pattern-match/match-iflet.md | 4 +++- zh-CN/src/pattern-match/patterns.md | 4 +++- zh-CN/src/variables.md | 4 +++- 32 files changed, 85 insertions(+), 24 deletions(-) diff --git a/src/basic-types/char-bool-unit.md b/src/basic-types/char-bool-unit.md index faac527..9bf7f75 100644 --- a/src/basic-types/char-bool-unit.md +++ b/src/basic-types/char-bool-unit.md @@ -87,4 +87,6 @@ fn main() { let unit: () = (); assert!(size_of_val(&unit) == 4); } -``` \ No newline at end of file +``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/basic-types/functions.md b/src/basic-types/functions.md index 83910e1..67ddb47 100644 --- a/src/basic-types/functions.md +++ b/src/basic-types/functions.md @@ -40,4 +40,6 @@ fn never_return() -> ! { // implement this function, don't modify fn signatures } -``` \ No newline at end of file +``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/basic-types/numbers.md b/src/basic-types/numbers.md index 60c5aa0..2c86954 100644 --- a/src/basic-types/numbers.md +++ b/src/basic-types/numbers.md @@ -163,3 +163,5 @@ fn main() { println!("0x80 >> 2 is 0x{:x}", 0x80u32 >> 2); } ``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/basic-types/statements-expressions.md b/src/basic-types/statements-expressions.md index c73db65..bbaf2e3 100644 --- a/src/basic-types/statements-expressions.md +++ b/src/basic-types/statements-expressions.md @@ -56,4 +56,6 @@ fn main() {} fn sum(x: i32, y: i32) -> i32 { x + y; } -``` \ No newline at end of file +``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/compound-types/array.md b/src/compound-types/array.md index 5dfcc0a..4a6e1d2 100644 --- a/src/compound-types/array.md +++ b/src/compound-types/array.md @@ -87,3 +87,4 @@ fn main() { ``` +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/compound-types/enum.md b/src/compound-types/enum.md index ad916d3..3f09e2f 100644 --- a/src/compound-types/enum.md +++ b/src/compound-types/enum.md @@ -70,7 +70,7 @@ fn main() { } ``` -🌟🌟 使用枚举对类型进行同一化 +🌟🌟 ```rust,editable @@ -198,4 +198,6 @@ fn main() { println!("linked list has length: {}", list.len()); println!("{}", list.stringify()); } -``` \ No newline at end of file +``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/compound-types/slice.md b/src/compound-types/slice.md index 30e3e68..29026a2 100644 --- a/src/compound-types/slice.md +++ b/src/compound-types/slice.md @@ -86,3 +86,5 @@ fn first_word(s: &str) -> &str { &s[..1] } ``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/compound-types/string.md b/src/compound-types/string.md index 685fc1f..034430e 100644 --- a/src/compound-types/string.md +++ b/src/compound-types/string.md @@ -251,5 +251,4 @@ fn main() { } ``` - - +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/compound-types/struct.md b/src/compound-types/struct.md index 58c8468..32f9360 100644 --- a/src/compound-types/struct.md +++ b/src/compound-types/struct.md @@ -213,4 +213,6 @@ fn main() { println!("{}, {}, {:?}",f.name, f.data, f); } -``` \ No newline at end of file +``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/compound-types/tuple.md b/src/compound-types/tuple.md index 0929bf1..55f1d3a 100644 --- a/src/compound-types/tuple.md +++ b/src/compound-types/tuple.md @@ -75,3 +75,5 @@ fn sum_multiply(nums: (i32, i32)) -> (i32, i32) { (nums.0 + nums.1, nums.0 * nums.1) } ``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/flow-control.md b/src/flow-control.md index 6b99e44..a7570a7 100644 --- a/src/flow-control.md +++ b/src/flow-control.md @@ -242,4 +242,6 @@ fn main() { assert!(count == __) } -``` \ No newline at end of file +``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/ownership/borrowing.md b/src/ownership/borrowing.md index 86ec6e4..23d1354 100644 --- a/src/ownership/borrowing.md +++ b/src/ownership/borrowing.md @@ -163,4 +163,6 @@ fn main() { // add one line below to make a compiler error: cannot borrow `s` as mutable more than once at a time // you can't use r1 and r2 at the same time } -``` \ No newline at end of file +``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/ownership/ownership.md b/src/ownership/ownership.md index d9b6252..0586cb1 100644 --- a/src/ownership/ownership.md +++ b/src/ownership/ownership.md @@ -161,3 +161,6 @@ fn main() { println!("{:?}, {:?}, {:?}", s1, s2, t); } ``` + + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/pattern-match/match-iflet.md b/src/pattern-match/match-iflet.md index a951610..a4dc682 100644 --- a/src/pattern-match/match-iflet.md +++ b/src/pattern-match/match-iflet.md @@ -193,3 +193,6 @@ fn main() { } } ``` + + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/pattern-match/patterns.md b/src/pattern-match/patterns.md index 2b2d752..fab9479 100644 --- a/src/pattern-match/patterns.md +++ b/src/pattern-match/patterns.md @@ -95,4 +95,6 @@ fn main() { } } } -``` \ No newline at end of file +``` + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/src/variables.md b/src/variables.md index 581364e..230195e 100644 --- a/src/variables.md +++ b/src/variables.md @@ -143,4 +143,7 @@ fn main() { // fill the blank to make the code work assert_eq!([x,y], __); } -``` \ No newline at end of file +``` + + +> You can find the solutions [here](https://github.com/sunface/rust-by-practice)(under the solutions path), but only use it when you need it \ No newline at end of file diff --git a/zh-CN/src/basic-types/char-bool-unit.md b/zh-CN/src/basic-types/char-bool-unit.md index 990c759..b464c52 100644 --- a/zh-CN/src/basic-types/char-bool-unit.md +++ b/zh-CN/src/basic-types/char-bool-unit.md @@ -84,4 +84,6 @@ fn main() { let unit: () = (); assert!(size_of_val(&unit) == 4); } -``` \ No newline at end of file +``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/basic-types/functions.md b/zh-CN/src/basic-types/functions.md index 4ee0b82..1a07c9e 100644 --- a/zh-CN/src/basic-types/functions.md +++ b/zh-CN/src/basic-types/functions.md @@ -40,4 +40,6 @@ fn never_return() -> ! { // 实现这个函数,不要修改函数签名! } -``` \ No newline at end of file +``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/basic-types/numbers.md b/zh-CN/src/basic-types/numbers.md index 87e58d3..9eee641 100644 --- a/zh-CN/src/basic-types/numbers.md +++ b/zh-CN/src/basic-types/numbers.md @@ -163,3 +163,5 @@ fn main() { println!("0x80 >> 2 is 0x{:x}", 0x80u32 >> 2); } ``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/basic-types/statements-expressions.md b/zh-CN/src/basic-types/statements-expressions.md index ab9766b..671f021 100644 --- a/zh-CN/src/basic-types/statements-expressions.md +++ b/zh-CN/src/basic-types/statements-expressions.md @@ -56,4 +56,6 @@ fn main() {} fn sum(x: i32, y: i32) -> i32 { x + y; } -``` \ No newline at end of file +``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/compound-types/array.md b/zh-CN/src/compound-types/array.md index 931fc05..5e9e710 100644 --- a/zh-CN/src/compound-types/array.md +++ b/zh-CN/src/compound-types/array.md @@ -83,3 +83,4 @@ fn main() { } ``` +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/compound-types/enum.md b/zh-CN/src/compound-types/enum.md index 42ac114..21ba5f5 100644 --- a/zh-CN/src/compound-types/enum.md +++ b/zh-CN/src/compound-types/enum.md @@ -189,4 +189,6 @@ fn main() { println!("链表的长度是: {}", list.len()); println!("{}", list.stringify()); } -``` \ No newline at end of file +``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/compound-types/slice.md b/zh-CN/src/compound-types/slice.md index 898f511..5d50c3e 100644 --- a/zh-CN/src/compound-types/slice.md +++ b/zh-CN/src/compound-types/slice.md @@ -88,3 +88,5 @@ fn first_word(s: &str) -> &str { &s[..1] } ``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/compound-types/string.md b/zh-CN/src/compound-types/string.md index 7cbcd08..1baf5c4 100644 --- a/zh-CN/src/compound-types/string.md +++ b/zh-CN/src/compound-types/string.md @@ -255,4 +255,4 @@ fn main() { ``` - +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/compound-types/struct.md b/zh-CN/src/compound-types/struct.md index b31a5f2..7e0a660 100644 --- a/zh-CN/src/compound-types/struct.md +++ b/zh-CN/src/compound-types/struct.md @@ -215,4 +215,6 @@ fn main() { println!("{}, {}, {:?}",f.name, f.data, f); } ``` -``` + + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) diff --git a/zh-CN/src/compound-types/tuple.md b/zh-CN/src/compound-types/tuple.md index a0f4332..60597bb 100644 --- a/zh-CN/src/compound-types/tuple.md +++ b/zh-CN/src/compound-types/tuple.md @@ -75,3 +75,6 @@ fn sum_multiply(nums: (i32, i32)) -> (i32, i32) { (nums.0 + nums.1, nums.0 * nums.1) } ``` + + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/flow-control.md b/zh-CN/src/flow-control.md index 826db33..d224389 100644 --- a/zh-CN/src/flow-control.md +++ b/zh-CN/src/flow-control.md @@ -240,4 +240,6 @@ fn main() { assert!(count == __) } -``` \ No newline at end of file +``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/ownership/borrowing.md b/zh-CN/src/ownership/borrowing.md index f78c2be..f29fabb 100644 --- a/zh-CN/src/ownership/borrowing.md +++ b/zh-CN/src/ownership/borrowing.md @@ -163,4 +163,6 @@ fn main() { // 在下面增加一行代码人为制造编译错误:cannot borrow `s` as mutable more than once at a time // 你不能同时使用 r1 和 r2 } -``` \ No newline at end of file +``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/ownership/ownership.md b/zh-CN/src/ownership/ownership.md index 2e506ca..22330af 100644 --- a/zh-CN/src/ownership/ownership.md +++ b/zh-CN/src/ownership/ownership.md @@ -164,4 +164,6 @@ fn main() { println!("{:?}, {:?}, {:?}", s1, s2, t); } -``` \ No newline at end of file +``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/pattern-match/match-iflet.md b/zh-CN/src/pattern-match/match-iflet.md index 60208f8..9f58a52 100644 --- a/zh-CN/src/pattern-match/match-iflet.md +++ b/zh-CN/src/pattern-match/match-iflet.md @@ -192,4 +192,6 @@ fn main() { _ => () } } - ``` +``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/pattern-match/patterns.md b/zh-CN/src/pattern-match/patterns.md index 0894345..dd31d91 100644 --- a/zh-CN/src/pattern-match/patterns.md +++ b/zh-CN/src/pattern-match/patterns.md @@ -95,4 +95,6 @@ fn main() { } } } -``` \ No newline at end of file +``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file diff --git a/zh-CN/src/variables.md b/zh-CN/src/variables.md index 2bfc02f..b2193e0 100644 --- a/zh-CN/src/variables.md +++ b/zh-CN/src/variables.md @@ -141,4 +141,6 @@ fn main() { // 填空,让代码工作 assert_eq!([x,y], __); } -``` \ No newline at end of file +``` + +> 你可以在[这里](https://github.com/sunface/rust-by-practice)找到答案(在 solutions 路径下) \ No newline at end of file