Created
December 28, 2018 10:15
-
-
Save rust-play/08b90ef2aac1c75f72009e9f51707154 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains 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::thread; | |
struct Shitpointer(*mut i32); | |
unsafe impl Send for Shitpointer {} | |
fn main() { | |
let mut v: Vec<i32> = vec![1, 3, 3, 7]; | |
let ptr_1 = Shitpointer(v.as_mut_ptr()); | |
let ptr_2 = Shitpointer(v.as_mut_ptr()); | |
let t_1 = thread::spawn(move || unsafe { *ptr_1.0.offset(0) += 1}); | |
let t_2 = thread::spawn(move || unsafe { *ptr_2.0.offset(3) += 20}); | |
t_1.join(); | |
t_2.join(); | |
println!("{:?}", v); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment