Skip to content

Instantly share code, notes, and snippets.

@nikomatsakis
Created May 18, 2012 21:01
Show Gist options
  • Save nikomatsakis/2727600 to your computer and use it in GitHub Desktop.
Save nikomatsakis/2727600 to your computer and use it in GitHub Desktop.
// 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