aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-07-24 15:58:30 +0200
committerHampusM <hampus@hampusmat.com>2022-07-24 15:58:30 +0200
commit5335cdad99a6d566ea6e83f97012c7954ba93c45 (patch)
treeb4c91634b34f6d3858d6dd210afb609d9a1f76d7 /src/lib.rs
parent5ea16d1e5bf716831bc8c54c5c4c86229d7e0463 (diff)
feat: add support for generics
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 5724f10..cb0dd5a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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);
+ };
+}