static-dispatch 0.3.0

Implement a trait for an enum, where all variants implement the trait
Documentation
use crate::other_module::ExternBehavior;

mod other_module {
    #[static_dispatch::setup]
    pub trait ExternBehavior {
        fn something(&self);
    }
}

struct A;
impl ExternBehavior for A {
    fn something(&self) {}
}

struct B;
impl ExternBehavior for B {
    fn something(&self) {}
}

#[static_dispatch::setup]
enum Something {
    A(A),
    B(B),
}

static_dispatch::implementation!(other_module::ExternBehavior for Something);

#[test]
fn other_module() {
    let mut something = Something::A(A);
    something.something();
    something = Something::B(B);
    something.something();
}