libpenis 0.1.6

A rust port of https://github.com/todashuta/libpenis
Documentation
use std::sync::atomic::Ordering;

//Creates the balls and dick head
mod atomics {
    use std::sync::atomic::AtomicUsize;

    pub static BALLS: AtomicUsize = AtomicUsize::new(0);
    pub static DICK_HEAD: AtomicUsize = AtomicUsize::new(0);
}

pub fn set_balls(balls: usize) {
    atomics::BALLS.store(balls, Ordering::SeqCst);
}

pub fn set_dick_head(head: usize) {
    atomics::DICK_HEAD.store(head, Ordering::SeqCst);
}

//The following 2 functions can be used to read values in a more clean way
pub fn get_balls() -> usize {
    atomics::BALLS.load(Ordering::SeqCst)
}

pub fn get_dick_head() -> usize {
    atomics::DICK_HEAD.load(Ordering::SeqCst)
}

#[cfg(test)]
mod tests {
    use crate::{set_balls, set_dick_head, get_balls, get_dick_head};

    #[test]
    fn assign_and_read() {
        set_balls(1);
        set_dick_head(1);

        let B = get_balls();
        let D = get_dick_head();

        if B==D {
            println!("Success!");
        } else {
            panic!("Dick did not equal.");
        }
    }
}