use locktree::{locktree, New, Mutex, plug::PlugLifetime, PluggedGuard}; use std::marker::PhantomData; locktree! { Main { // Use a dummy lock that does nothing becase will deadlock by trying to // acquire the same lock twice mutex: Mutex(DummyLock)<()> } } struct DummyLock(PhantomData); impl New for DummyLock { fn new(_: T) -> Self { Self(PhantomData) } } impl Mutex for DummyLock { type Guard = DummyGuard; fn lock(&self) -> PluggedGuard { DummyGuard } } struct DummyGuard; impl<'a> PlugLifetime<'a> for DummyGuard { type Type = DummyGuard; } fn main() { let locks = MainLockTree::new(()); let _a = locks.lock_mutex(); let _ = locks.lock_mutex(); }