sendify 1.1.0

An unsafe crate to wrap a reference to make it Send + Sync.
Documentation
  • Coverage
  • 71.43%
    5 out of 7 items documented1 out of 3 items with examples
  • Size
  • Source code size: 12.12 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.65 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • rousan/sendify-rs
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rousan

Github Actions Status crates.io Documentation MIT

sendify-rs

An unsafe crate to wrap a reference to make it Send + Sync to be able to transfer it between threads. Make sure the reference is still valid when unwrapping it.

Docs

Install

Add this to your Cargo.toml file:

[dependencies]
sendify = "1.1"

Example

use std::thread;

fn main() {
    let data = "my string".to_owned();

    let ref_val = &data;
    // Wrap the reference to make it Send + Sync.
    let sendify_val = sendify::wrap(ref_val);

    thread::spawn(move || {
        // Unwrap the reference, here make sure that reference is still valid otherwise
        // the app might crash.
        let ref_val = unsafe { sendify_val.unwrap() };
        assert_eq!(ref_val, "my string")
    })
    .join()
    .unwrap();

    assert_eq!(data, "my string")
}

Contributing

Your PRs and suggestions are always welcome.