Skip to main content

Crate struct_threads

Crate struct_threads 

Source
Expand description

A simple library providing a clean, object-oriented way to structure thread logic.

struct-threads allows you to define your task state in a struct, implement the Runnable trait, and seamlessly spawn it using the Thread extension trait.

§Example

use struct_threads::{Runnable, Thread};

struct MyTask(i32);

impl Runnable for MyTask {
    type Output = i32;

    fn run(self) -> Self::Output {
        self.0 * 2
    }
}

let handle = MyTask(21).start();
assert_eq!(handle.join().unwrap(), 42);

Re-exports§

pub use traits::Runnable;
pub use traits::Thread;

Modules§

traits