swapper 0.1.0

Swap ownership between threads
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
extern crate swapper;

use std::thread;
use swapper::swapper;

#[test]
fn test() {
    let (us, them) = swapper();
    let helper = thread::spawn(move || {
        let mut hello = String::from("hello");
        them.swap(&mut hello).unwrap();
        assert_eq!(hello, "world");
    });
    let mut world = String::from("world");
    us.swap(&mut world).unwrap();
    assert_eq!(world, "hello");
    helper.join().unwrap();
}