Thanks, Kevin! On 29 Jan 2014, at 00:12, Kevin Ballard <[email protected]> wrote:
> Your code is moving the contents of Option<~MyStruct> into the match arm. It > just so happens that this seems to be zeroing out the original pointer in > memory, and that happens to be the same representation that None does for the > type Option<~MyStruct> (since ~ pointers are non-nullable), so the act of > moving the value just happens to be transforming it into a None. > > Normally you couldn't do this, but mutable statics are weird (which is why > you need the unsafe block to access it). > > When you remove the ~, the lines end up printing the same because MyStruct is > implicitly copyable, so your match arm is now copying instead of moving. > > The correct fix here is to use `Some(ref data)` instead of `Some(data)`. This > will take a reference to the data instead of moving it, and the static will > remain unchanged. > > -Kevin
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
