Skip to content

Instantly share code, notes, and snippets.

@jdm
Created July 22, 2013 20:25
Show Gist options
  • Save jdm/6057331 to your computer and use it in GitHub Desktop.
Save jdm/6057331 to your computer and use it in GitHub Desktop.
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
}));
}
@jdm
Copy link
Author

jdm commented Jul 22, 2013

/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);
^~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment