aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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);
+ };
+}