#send-sync #unsafe #wrapper #structs #struct #and-or

unsafe-send-sync

Unsafe wrappers for making structs Send and/or Sync

5 releases

0.1.0 Nov 19, 2020
0.0.3 Nov 3, 2020
0.0.2 Nov 3, 2020
0.0.1 Nov 3, 2020
0.0.0 Nov 3, 2020

#8 in #send-sync

Download history 114/week @ 2023-11-20 10/week @ 2023-12-25 41/week @ 2024-01-01 40/week @ 2024-01-08 54/week @ 2024-01-15 16/week @ 2024-01-22 7/week @ 2024-01-29 79/week @ 2024-02-05 124/week @ 2024-02-12 74/week @ 2024-02-19 120/week @ 2024-02-26 150/week @ 2024-03-04

471 downloads per month
Used in browser-window

MIT license

5KB
104 lines

Unsafe Send Sync

This is a Rust package that basically provides 3 wrapper types.

  • UnsafeSend
  • UnsafeSync
  • UnsafeSendSync

They can be used to force structs to be Send and/or Sync, which is unsafe of course.

Example

use std::thread;
use std::rc::Rc;

fn main() {
    let not_send = UnsafeSend::new( Rc::<u32>::new( 1337 ) );
    
    assert!( not_send.strong_count() == 1,
        "We can't really send a reference counted pointer across threads unless it only has one reference." );
    
    thread::spawn(move || {
        println!("We found a number: {}", *not_send);
    });
}

No runtime deps