diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -22,3 +22,20 @@ pub mod libs; // Private mod provider; + +/// Shortcut for creating a DI container binding for a injectable without a declared interface. +/// +/// This will declare a interface for the implementation. +/// +/// Useful for when the implementation or the interface is generic. +/// +/// # Arguments +/// {interface} => {implementation}, {DI container variable name} +#[macro_export] +macro_rules! di_container_bind { + ($interface: path => $implementation: ty, $di_container: ident) => { + $di_container.bind::<dyn $interface>().to::<$implementation>(); + + syrette::declare_interface!($implementation -> $interface); + }; +} |