Update codes of ch2

This commit is contained in:
Aaran Xu 2022-02-02 16:24:47 +08:00
parent bb019b48b0
commit ea43bbd056
43 changed files with 57 additions and 50 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "functions" name = "functions"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "branches" name = "branches"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "loops" name = "loops"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "loops" name = "loops"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "loops" name = "loops"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "variables" name = "variables"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "variables" name = "variables"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "variables" name = "variables"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "variables" name = "variables"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "variables" name = "variables"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -3,6 +3,8 @@ $ cargo run
error[E0308]: mismatched types error[E0308]: mismatched types
--> src/main.rs:3:14 --> src/main.rs:3:14
| |
2 | let mut spaces = " ";
| ----- expected due to this value
3 | spaces = spaces.len(); 3 | spaces = spaces.len();
| ^^^^^^^^^^^^ expected `&str`, found `usize` | ^^^^^^^^^^^^ expected `&str`, found `usize`

View File

@ -1,6 +1,6 @@
[package] [package]
name = "floating-point" name = "floating-point"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "numeric-operations" name = "numeric-operations"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "boolean" name = "boolean"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "char" name = "char"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tuples" name = "tuples"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tuples" name = "tuples"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tuples" name = "tuples"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "arrays" name = "arrays"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "arrays" name = "arrays"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "arrays" name = "arrays"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "functions" name = "functions"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "functions" name = "functions"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "functions" name = "functions"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "functions" name = "functions"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,5 +1,13 @@
$ cargo run $ cargo run
Compiling functions v0.1.0 (file:///projects/functions) Compiling functions v0.1.0 (file:///projects/functions)
error: expected expression, found statement (`let`)
--> src/main.rs:2:14
|
2 | let x = (let y = 6);
| ^^^^^^^^^
|
= note: variable declaration using `let` is a statement
error[E0658]: `let` expressions in this position are experimental error[E0658]: `let` expressions in this position are experimental
--> src/main.rs:2:14 --> src/main.rs:2:14
| |
@ -9,21 +17,18 @@ error[E0658]: `let` expressions in this position are experimental
= note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information
= help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>` = help: you can write `matches!(<expr>, <pattern>)` instead of `let <pattern> = <expr>`
error: expected expression, found statement (`let`)
--> src/main.rs:2:14
|
2 | let x = (let y = 6);
| ^^^^^^^^^
|
= note: variable declaration using `let` is a statement
warning: unnecessary parentheses around assigned value warning: unnecessary parentheses around assigned value
--> src/main.rs:2:13 --> src/main.rs:2:13
| |
2 | let x = (let y = 6); 2 | let x = (let y = 6);
| ^^^^^^^^^^^ help: remove these parentheses | ^ ^
| |
= note: `#[warn(unused_parens)]` on by default = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
|
2 - let x = (let y = 6);
2 + let x = let y = 6;
|
For more information about this error, try `rustc --explain E0658`. For more information about this error, try `rustc --explain E0658`.
warning: `functions` (bin "functions") generated 1 warning warning: `functions` (bin "functions") generated 1 warning

View File

@ -1,6 +1,6 @@
[package] [package]
name = "functions" name = "functions"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "functions" name = "functions"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "functions" name = "functions"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "functions" name = "functions"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "comments" name = "comments"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "comments" name = "comments"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "branches" name = "branches"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "branches" name = "branches"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "branches" name = "branches"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "branches" name = "branches"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "branches" name = "branches"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "branches" name = "branches"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "loops" name = "loops"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "loops" name = "loops"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "loops" name = "loops"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,6 +1,6 @@
[package] [package]
name = "loops" name = "loops"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
[dependencies] [dependencies]

View File

@ -1,7 +1,7 @@
[package] [package]
name = "no_type_annotations" name = "no_type_annotations"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html