mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-24 04:59:41 +00:00
add solutions for variables
This commit is contained in:
@ -87,4 +87,6 @@ fn main() {
|
||||
let unit: () = ();
|
||||
assert!(size_of_val(&unit) == 4);
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
> 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
|
@ -40,4 +40,6 @@ fn never_return() -> ! {
|
||||
// implement this function, don't modify fn signatures
|
||||
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
> 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
|
@ -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
|
@ -56,4 +56,6 @@ fn main() {}
|
||||
fn sum(x: i32, y: i32) -> i32 {
|
||||
x + y;
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
> 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
|
@ -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
|
@ -70,7 +70,7 @@ fn main() {
|
||||
}
|
||||
```
|
||||
|
||||
🌟🌟 使用枚举对类型进行同一化
|
||||
🌟🌟
|
||||
|
||||
```rust,editable
|
||||
|
||||
@ -198,4 +198,6 @@ fn main() {
|
||||
println!("linked list has length: {}", list.len());
|
||||
println!("{}", list.stringify());
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
> 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
|
@ -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
|
@ -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
|
@ -213,4 +213,6 @@ fn main() {
|
||||
|
||||
println!("{}, {}, {:?}",f.name, f.data, f);
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
> 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
|
@ -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
|
@ -242,4 +242,6 @@ fn main() {
|
||||
|
||||
assert!(count == __)
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
> 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
|
@ -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
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
> 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
|
@ -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
|
@ -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
|
@ -95,4 +95,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
|
@ -143,4 +143,7 @@ fn main() {
|
||||
// fill the blank to make the code work
|
||||
assert_eq!([x,y], __);
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
|
||||
> 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
|
Reference in New Issue
Block a user