Earlier quoted context omitted.
It does seem like satire. The very first example is: fn main() { let a = String::from("hello"); let b = a; println!("{a}"); // Works! Prints: hello } This is not “I have correct code but Rust can’t tell it’s correct.” This is “wow, this code is intentionally outrageously wrong, obviously dereferences a pointer that is invalid, and happens to work anyway.”
> this code is intentionally outrageously wrong Can you explain why? Why can't both a and b point at the same string object? Does `let b = a;` do something like a destructive move?
error[E0382]: borrow of moved value: `a`
--> main.rs:4:16
|
2 | let a = String::from("hello");
| - move occurs because `a` has type `String`, which does not implement the `Copy` trait
3 | let b = a;
| - value moved here
4 | println!("{a}"); // Works! Prints: hello
| ^ value borrowed here after move
|
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider cloning the value if the performance cost is acceptable
|
3 | let b = a.clone();
| ++++++++