diff options
author | HampusM <hampus@hampusmat.com> | 2022-07-24 15:58:30 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-07-24 15:58:30 +0200 |
commit | 5335cdad99a6d566ea6e83f97012c7954ba93c45 (patch) | |
tree | b4c91634b34f6d3858d6dd210afb609d9a1f76d7 /src/lib.rs | |
parent | 5ea16d1e5bf716831bc8c54c5c4c86229d7e0463 (diff) |
feat: add support for generics
Diffstat (limited to 'src/lib.rs')
-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); + }; +} |