mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 04:29:41 +00:00
Merge branch 'sunface:master' into master
This commit is contained in:
@ -174,7 +174,7 @@ use std::ops;
|
|||||||
// Implement fn multiply to make the code work.
|
// Implement fn multiply to make the code work.
|
||||||
// As mentioned above, `+` needs `T` to implement `std::ops::Add` Trait.
|
// As mentioned above, `+` needs `T` to implement `std::ops::Add` Trait.
|
||||||
// So, what about `*`? You can find the answer here: https://doc.rust-lang.org/core/ops/
|
// So, what about `*`? You can find the answer here: https://doc.rust-lang.org/core/ops/
|
||||||
fn multipl
|
fn multiply
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
assert_eq!(6, multiply(2u8, 3u8));
|
assert_eq!(6, multiply(2u8, 3u8));
|
||||||
@ -469,4 +469,4 @@ fn main() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
> You can find the solutions [here](https://github.com/sunface/rust-by-practice/blob/master/solutions/generics-traits/traits.md)(under the solutions path), but only use it when you need it :)
|
> You can find the solutions [here](https://github.com/sunface/rust-by-practice/blob/master/solutions/generics-traits/traits.md)(under the solutions path), but only use it when you need it :)
|
||||||
|
@ -38,9 +38,9 @@ fn main() {
|
|||||||
let x: i32 = 10;
|
let x: i32 = 10;
|
||||||
{
|
{
|
||||||
let y: i32 = 5;
|
let y: i32 = 5;
|
||||||
println!("The value of x is {} and value of y is {}", x, y);
|
println!("Inner scope value of x is {} and value of y is {}", x, y);
|
||||||
}
|
}
|
||||||
println!("The value of x is {} and value of y is {}", x, y);
|
println!("Outer scope value of x is {} and value of y is {}", x, y);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -180,3 +180,5 @@ fn main() {
|
|||||||
println!("Hello {{}}"); // => Hello {}
|
println!("Hello {{}}"); // => Hello {}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
> 你可以在[这里](https://github.com/sunface/rust-by-practice/blob/master/solutions/formatted-output/formatting.md)找到答案(在 solutions 路径下)
|
||||||
|
Reference in New Issue
Block a user