Created
May 18, 2012 21:01
-
-
Save nikomatsakis/2727600 to your computer and use it in GitHub Desktop.
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
// xfail-fast (compile-flags unsupported on windows) | |
// compile-flags:--borrowck=err | |
// exec-env:RUST_POISON_ON_FREE=1 | |
fn main() { | |
let x: @mut @option<~int> = @mut @none; | |
alt x { | |
@@some(y) { | |
// here, the refcount of `*x` is bumped so | |
// `y` remains valid even if `*x` is modified. | |
*x = @none; | |
} | |
@@none { | |
// here, no bump of the ref count of `*x` is needed, but in | |
// fact a bump occurs anyway because of how pattern marching | |
// works. | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment