Created
July 22, 2013 20:25
-
-
Save jdm/6057331 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
use std::io; | |
use std::cast::*; | |
use std::unstable::intrinsics::*; | |
struct S{x:int,y:int} | |
fn foo(sp: &mut S) { | |
io::println(fmt!("%?", unsafe{ | |
//let sp = &s; | |
let mut t = uninit(); | |
move_val_init(&mut t,*sp); | |
t | |
})); | |
} | |
fn foo2<T>(sp: &mut T) { | |
io::println(fmt!("%?", unsafe{ | |
let mut t = uninit(); | |
move_val_init(&mut t,*sp); | |
t | |
})); | |
} | |
fn main() { | |
let mut s = S{x:4,y:3}; | |
foo(&mut s); | |
foo2(&mut s); | |
io::println(fmt!("%?", unsafe{ | |
let sp = &s; | |
let mut t = uninit(); | |
move_val_init(&mut t,*transmute_mut(sp)); | |
t | |
})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/tmp/foo.rs:16:23: 16:26 error: cannot move out of dereference of & pointer
/tmp/foo.rs:16 move_val_init(&mut t,*sp);
^~~