Macro simple_share

Source
macro_rules! simple_share {
    ($data:expr) => { ... };
}
Expand description

Macro for creating SimpleShare

This macro creates a SimpleShare<T> instance for basic data sharing without change detection capabilities.

§Syntax

simple_share!(expression)

§Arguments

  • expression - The data to wrap in SimpleShare

§Returns

A new SimpleShare<T> instance where T is inferred from the expression.

§Example

use thread_share::simple_share;

// Basic types
let counter = simple_share!(0);             // SimpleShare<i32>
let message = simple_share!("Hello");       // SimpleShare<&str>
let flag = simple_share!(false);            // SimpleShare<bool>

// Complex types
let data = simple_share!(vec![1, 2, 3]);   // SimpleShare<Vec<i32>>
// let user = simple_share!(User { id: 1, name: "Bob" }); // SimpleShare<User>

§When to Use

Use simple_share! when you need:

  • Basic data sharing without change detection
  • Minimal overhead and complexity
  • Simple producer-consumer patterns
  • Learning and prototyping

Use share! when you need:

  • Change detection and waiting mechanisms
  • Complex synchronization patterns
  • Maximum flexibility and features