shared-struct 0.1.1

Proc-macro for turning a struct into a shared concurrent wrapper
Documentation
use shared_struct::shared;

#[shared]
pub struct Context {
    pub col1: String,
    pub col2: u32,
}

#[shared]
pub struct Mixed {
    pub mutex_field: String,
    #[raw]
    pub raw_field: u32,
}

#[tokio::test]
async fn test_new_and_read() {
    let ctx = Context::new("hello".to_string(), 42);
    assert_eq!(*ctx.col1().await, "hello");
    assert_eq!(*ctx.col2().await, 42);
}

#[tokio::test]
async fn test_mutate() {
    let ctx = Context::new("hello".to_string(), 0);
    *ctx.col1().await += " world";
    assert_eq!(*ctx.col1().await, "hello world");
}

#[tokio::test]
async fn test_clone_is_shared() {
    let ctx = Context::new("a".to_string(), 1);
    let ctx2 = ctx.clone();
    *ctx.col1().await = "b".to_string();
    assert_eq!(*ctx2.col1().await, "b");
}

#[tokio::test]
async fn test_raw_field() {
    let m = Mixed::new("mutex".to_string(), 99);
    assert_eq!(*m.raw_field(), 99);
}