Skip to content

Instantly share code, notes, and snippets.

@Amanieu
Created August 4, 2016 19:33
Show Gist options
  • Save Amanieu/2ef2294e4547df6d7dd3c25452399234 to your computer and use it in GitHub Desktop.
Save Amanieu/2ef2294e4547df6d7dd3c25452399234 to your computer and use it in GitHub Desktop.
mem::transmute_copy(&(*(dst as *const AtomicU8)).swap(mem::transmute_copy(&val), order))
-----
let atomic = &*(dst as *const AtomicU8);
let new = mem::transmute_copy(&val);
let old = atomic.swap(new);
mem::transmute_copy(&old)
ptr::read(&(*(dst as *const AtomicU8)).swap(ptr::read(&val as *const _ as *const u8), order) as *const _ as *const u8)
-----
let atomic = &*(dst as *const AtomicU8);
let new = ptr::read(&val as *const _ as *const u8);
let old = atomic.swap(new);
ptr::read(&old as *const u8 as *const _)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment