add destructuring assignments

This commit is contained in:
sunface
2022-02-25 11:18:27 +08:00
parent 1371c86e3f
commit f393232de1
10 changed files with 926 additions and 5 deletions

View File

@ -116,4 +116,23 @@ fn main() {
assert_eq!(x, 3);
assert_eq!(y, 2);
}
```
### Destructuring assignments
🌟🌟 fix the code with two ways:
- Shadowing with adding `let`
- make types compatible
> Note: the feature `Destructuring assignments` need 1.59 or higher Rust version
```rust,editable
fn main() {
let (mut x, mut y) = (1.0, 2.0);
(x,y) = (3, 4);
assert_eq!([x,y],[3, 4]);
}
```