#![cfg(feature = "thread_safe")]
use shaku::{module, Component, Interface, ModuleInterface};
trait TestComponent: Interface {}
trait TestSubmodule: ModuleInterface {}
#[derive(Component)]
#[shaku(interface = TestComponent)]
struct TestComponentImpl;
impl TestComponent for TestComponentImpl {}
module! {
TestModule {
components = [TestComponentImpl],
providers = [],
use TestSubmodule {
components = [],
providers = []
}
}
}
fn assert_threadsafe<T: Send + Sync + ?Sized>() {}
#[test]
fn components_are_threadsafe() {
assert_threadsafe::<dyn TestComponent>();
}
#[test]
fn modules_are_threadsafe() {
assert_threadsafe::<dyn TestSubmodule>();
}
#[test]
fn modules_with_submodules_are_threadsafe() {
assert_threadsafe::<TestModule>();
}