Last active
January 3, 2026 14:09
-
-
Save trungnt13/ce294ef7061c84868e92d77e1eeb2740 to your computer and use it in GitHub Desktop.
Revisions
-
trungnt13 revised this gist
Jun 11, 2024 . No changes.There are no files selected for viewing
-
trungnt13 revised this gist
Jun 11, 2024 . No changes.There are no files selected for viewing
-
trungnt13 revised this gist
Jun 11, 2024 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -89,8 +89,6 @@ Too many `Cargo.toml` files in the workspace, set this: "CARGO_HOME": "/home/tngo/codes/ml3x/insim/build/.cargo" }, ``` --- ## Control Flow -
trungnt13 revised this gist
Jun 11, 2024 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,7 @@ - [VSCode and rust-analyzer](#vscode-and-rust-analyzer) - [rust-analyzer failed to discover workspace](#rust-analyzer-failed-to-discover-workspace) - [rust-analyzer block build](#rust-analyzer-block-build) - [rust-analyzer CARGO\_HOME](#rust-analyzer-cargo_home) - [Control Flow](#control-flow) - [If-then-else](#if-then-else) - [Match](#match) @@ -81,6 +82,15 @@ Too many `Cargo.toml` files in the workspace, set this: ] ``` ### rust-analyzer CARGO_HOME ```json "rust-analyzer.server.extraEnv": { "CARGO_HOME": "/home/tngo/codes/ml3x/insim/build/.cargo" }, ``` --- ## Control Flow -
trungnt13 revised this gist
Jun 10, 2024 . No changes.There are no files selected for viewing
-
trungnt13 revised this gist
Jun 10, 2024 . No changes.There are no files selected for viewing
-
trungnt13 revised this gist
Jun 10, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,7 @@ - [Rust](#rust) - [VSCode and rust-analyzer](#vscode-and-rust-analyzer) - [rust-analyzer failed to discover workspace](#rust-analyzer-failed-to-discover-workspace) - [rust-analyzer block build](#rust-analyzer-block-build) - [Control Flow](#control-flow) - [If-then-else](#if-then-else) - [Match](#match) -
trungnt13 revised this gist
Jun 5, 2024 . No changes.There are no files selected for viewing
-
trungnt13 revised this gist
Jun 5, 2024 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -75,7 +75,9 @@ Too many `Cargo.toml` files in the workspace, set this: ### rust-analyzer block build ```json "rust-analyzer.check.extraArgs": [ "--target-dir=target/rust-analyzer" ] ``` --- -
trungnt13 revised this gist
Jun 5, 2024 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -78,7 +78,6 @@ Too many `Cargo.toml` files in the workspace, set this: "rust-analyzer.cargo.loadOutDirsFromCheck": true ``` --- ## Control Flow -
trungnt13 revised this gist
Jun 5, 2024 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -72,6 +72,13 @@ Too many `Cargo.toml` files in the workspace, set this: ] ``` ### rust-analyzer block build ```json "rust-analyzer.cargo.loadOutDirsFromCheck": true ``` --- ## Control Flow -
trungnt13 revised this gist
May 28, 2024 . No changes.There are no files selected for viewing
-
trungnt13 revised this gist
Apr 27, 2024 . No changes.There are no files selected for viewing
-
trungnt13 revised this gist
Apr 27, 2024 . No changes.There are no files selected for viewing
-
trungnt13 revised this gist
Apr 26, 2024 . No changes.There are no files selected for viewing
-
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -241,6 +241,7 @@ fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let y = &x[0]; // OK let z = y.unwrap(); // ERROR: cannot move out of y because it's borrowed reference let z = (*y).unwrap(); // ERROR: same as above, automatic dereference here let z0: String = x[0].clone().unwrap(); // OK let z1: &String = x[0].as_ref().unwrap(); // OK } -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -240,7 +240,7 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let y = &x[0]; // OK let z = y.unwrap(); // ERROR: cannot move out of y because it's borrowed reference let z0: String = x[0].clone().unwrap(); // OK let z1: &String = x[0].as_ref().unwrap(); // OK } -
trungnt13 revised this gist
Apr 26, 2024 . No changes.There are no files selected for viewing
-
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -240,7 +240,7 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let y = &x[0]; // OK let z0 = y.unwrap(); // ERROR: cannot move out of y because it's borrowed reference let z0: String = x[0].clone().unwrap(); // OK let z1: &String = x[0].as_ref().unwrap(); // OK } -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -240,7 +240,7 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let y = &x[0]; // OK let z0 = y.clone().unwrap(); // ERROR: cannot move out of y because it's borrowed reference let z0: String = x[0].clone().unwrap(); // OK let z1: &String = x[0].as_ref().unwrap(); // OK } -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -239,8 +239,8 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar ```rust fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let y = &x[0]; // OK let z0 = y.clone().unwrap(); // ERROR: cannot move out of y because it's borrowed let z0: String = x[0].clone().unwrap(); // OK let z1: &String = x[0].as_ref().unwrap(); // OK } -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -239,7 +239,7 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar ```rust fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let y = x[0].unwrap(); // ERROR: cannot move out of x let y = &x[0]; // OK let z0: String = x[0].clone().unwrap(); // OK let z1: &String = x[0].as_ref().unwrap(); // OK -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -239,7 +239,7 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar ```rust fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let y = x[0].unwrap(); // ERROR let y = &x[0]; // OK let z0: String = x[0].clone().unwrap(); // OK let z1: &String = x[0].as_ref().unwrap(); // OK -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -239,6 +239,8 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar ```rust fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let y = x[0] let y = &x[0]; // OK let z0: String = x[0].clone().unwrap(); // OK let z1: &String = x[0].as_ref().unwrap(); // OK } -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -239,9 +239,8 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar ```rust fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let z0: String = x[0].clone().unwrap(); // OK let z1: &String = x[0].as_ref().unwrap(); // OK } ``` -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -239,7 +239,7 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar ```rust fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let z0: String = x[0].clone().unwrap(); let z1 = x[0].as_ref().unwrap(); } -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -239,7 +239,7 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar ```rust fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let z0 = x[0].clone().unwrap(); let z1 = x[0].as_ref().unwrap(); } -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -239,6 +239,9 @@ When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the ar ```rust fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR let z0 = x[0].clone().unwrap(); let z1 = x[0].as_ref().unwrap(); } ``` -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -235,8 +235,8 @@ Compiler ensures: In Rust, variables are moved by default when you assign them to another variable or pass them to a function. This means that the original variable can no longer be used after the move. When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the array. This is not allowed because the size of the array is fixed, and moving an element out would leave a hole. ```rust fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR } -
trungnt13 revised this gist
Apr 26, 2024 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -234,9 +234,9 @@ Compiler ensures: ### Move Out of an Array In Rust, variables are moved by default when you assign them to another variable or pass them to a function. This means that the original variable can no longer be used after the move. When you assign `x[0]` to `y`, you are moving the `Option<String>` out of the array. This is not allowed because the size of the array is fixed, and moving an element out would leave a hole. ```rust fn pr(x: [Option<String>; 4]) { let y = x[0]; // ERROR }
NewerOlder