forked from KaiserY/trpl-zh-cn
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sefank <[email protected]>
- Loading branch information
Showing
23 changed files
with
33 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
listings/ch03-common-programming-concepts/no-listing-01-variables-are-immutable/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
fn main() { | ||
let x = 5; | ||
println!("The value of x is: {}", x); | ||
println!("The value of x is: {x}"); | ||
x = 6; | ||
println!("The value of x is: {}", x); | ||
println!("The value of x is: {x}"); | ||
} |
4 changes: 2 additions & 2 deletions
4
listings/ch03-common-programming-concepts/no-listing-02-adding-mut/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
fn main() { | ||
let mut x = 5; | ||
println!("The value of x is: {}", x); | ||
println!("The value of x is: {x}"); | ||
x = 6; | ||
println!("The value of x is: {}", x); | ||
println!("The value of x is: {x}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
listings/ch03-common-programming-concepts/no-listing-07-numeric-operations/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
fn main() { | ||
// 加法 | ||
// addition | ||
let sum = 5 + 10; | ||
|
||
// 减法 | ||
// subtraction | ||
let difference = 95.5 - 4.3; | ||
|
||
// 乘法 | ||
// multiplication | ||
let product = 4 * 30; | ||
|
||
// 除法 | ||
// division | ||
let quotient = 56.7 / 32.2; | ||
let floored = 2 / 3; // 结果为 0 | ||
let floored = 2 / 3; // Results in 0 | ||
|
||
// 取余 | ||
// remainder | ||
let remainder = 43 % 5; | ||
} |
2 changes: 1 addition & 1 deletion
2
listings/ch03-common-programming-concepts/no-listing-08-boolean/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
fn main() { | ||
let t = true; | ||
|
||
let f: bool = false; // 显式指定类型注解 | ||
let f: bool = false; // with explicit type annotation | ||
} |
2 changes: 1 addition & 1 deletion
2
listings/ch03-common-programming-concepts/no-listing-09-char/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
fn main() { | ||
let c = 'z'; | ||
let z = 'ℤ'; | ||
let z: char = 'ℤ'; // with explicit type annotation | ||
let heart_eyed_cat = '😻'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ fn main() { | |
|
||
let (x, y, z) = tup; | ||
|
||
println!("The value of y is: {}", y); | ||
println!("The value of y is: {y}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ fn main() { | |
x + 1 | ||
}; | ||
|
||
println!("The value of y is: {}", y); | ||
println!("The value of y is: {y}"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../ch03-common-programming-concepts/no-listing-22-function-parameter-and-return/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../ch03-common-programming-concepts/no-listing-23-statements-dont-return-values/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,5 @@ fn main() { | |
} | ||
}; | ||
|
||
println!("The result is {}", result); | ||
println!("The result is {result}"); | ||
} |
2 changes: 1 addition & 1 deletion
2
listings/ch03-common-programming-concepts/no-listing-34-for-range/src/main.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
fn main() { | ||
for number in (1..4).rev() { | ||
println!("{}!", number); | ||
println!("{number}!"); | ||
} | ||
println!("LIFTOFF!!!"); | ||
} |