Last active
December 14, 2015 03:29
-
-
Save jld/5021325 to your computer and use it in GitHub Desktop.
Rust has a bad day with side-effects.
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 characters
| struct S { x: int, y: int } | |
| fn effect(s: &str) -> S { io::println(s); S { x: 0, y: 0 } } | |
| pub fn main() { | |
| let _foo = S { x: 1, .. effect("this will be printed") }; | |
| let _ = S { x: 2, .. effect("and this won't") }; | |
| let _ = S { x: effect("but this will").y, .. effect("(still no)") }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment