Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created April 16, 2019 16:32
Show Gist options
  • Select an option

  • Save rust-play/7da60f49eefb4bf495c9c380715adf12 to your computer and use it in GitHub Desktop.

Select an option

Save rust-play/7da60f49eefb4bf495c9c380715adf12 to your computer and use it in GitHub Desktop.

Revisions

  1. rust-play created this gist Apr 16, 2019.
    15 changes: 15 additions & 0 deletions playground.rs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #![allow(mutable_transmutes)]
    use std::mem::transmute;

    fn main() {
    let a: Vec<u64> = Vec::new();
    let r = &a;
    let r: &mut Vec<u64> = unsafe { transmute(r) };
    r.push(1488);
    println!("{:?}", a);

    let x = &666;
    let y: *mut i32 = x as *const _ as *mut i32;
    unsafe { *y = 5 };
    println!("{:?}", x);
    }