SPEEDY_REFS

A collection of simple, Fast, and useful smart pointers for rust.

FEATURES

Upcoming

DEPENDENCIES

INSTALLATION

cargo add speedy_refs

[dependencies] speedy_refs = "0.2.5"

Example

Reon

``` use std::thread; use std::sync::{Arc, Barrier}; use speedy_refs::Reon;

fn main() { let x = Reon::new(42); let numthreads = 4; let barrier = Arc::new(Barrier::new(numthreads));

let mut threads = Vec::with_capacity(num_threads);

for _ in 0..num_threads {
    let x = x.clone();
    let barrier = Arc::clone(&barrier);
    let thread = thread::spawn(move || {
        barrier.wait();
        println!("Thread {:?} sees value: {}", thread::current().id(), *x);
    });
    threads.push(thread);
}

for thread in threads {
    thread.join().unwrap();
}

}

```

JavaCell

``` use speedy_refs::JavaCell;

fn main() { #[derive(Debug, PartialEq, Eq)] struct Data(String, usize, bool, Vec); let data = Data(String::from("Hello, World"), 100, false, vec![]); let mut cell = JavaCell::new(data); let mut clone = JavaCell::clone(&cell);

cell.0.push('!');
clone.1 += 55;
cell.2 = true;
clone.3.push(Data("".into(), 0, false, Vec::new()));

// Debug for JavaCell is same as that for Data
println!("{:?}", clone);
// Output
//Data("Hello, World!", 155, true, [Data("", 0, false, [])])
println!("{:?}", cell);
// Output
//Data("Hello, World!", 155, true, [Data("", 0, false, [])])


assert_eq!(*cell, Data(String::from("Hello, World!"), 155, true, vec![Data("".into(), 0, false, vec![])]));
assert_eq!(*clone, Data(String::from("Hello, World!"), 155, true, vec![Data("".into(), 0, false, vec![])]));

} ```

LICENSE

MIT license