February 2022
Intermediate to advanced
140 pages
2h 28m
English
| Puzzle 21 | Tying a Gordian Knot |
| | #[derive(Debug)] |
| | struct Parser<'a> { |
| | body: String, |
| | subtext : &'a str, |
| | } |
| | |
| | fn main() { |
| | let mut document = Parser { |
| | body: "Hello".to_string(), |
| | subtext: "" |
| | }; |
| | document.subtext = &document.body; |
| | |
| | let b = document; |
| | println!("{:?}", b); |
| | } |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
The program will fail to compile with the following message:
| | error[E0505]: cannot move out of `document` because it is borrowed |
| | --> ... |
Read now
Unlock full access