injectable-rs 0.1.0

A compile-time dependency injection framework for Rust using extractor-based DI
Documentation
//! Compile-fail test: multiple #[injectable(ctor)] methods.
//!
//! The #[injectable] attribute requires exactly one method
//! annotated with #[injectable(ctor)]. Having multiple is a compile error.

#![allow(unused_imports)]

use injectable_rs::injectable;

pub struct MyService {
    name: String,
}

#[injectable]
impl MyService {
    #[injectable(ctor)]
    pub fn new() -> Self {
        Self { name: "default".to_string() }
    }

    #[injectable(ctor)]
    pub fn from_name(name: String) -> Self {
        Self { name }
    }
}

fn main() {}