aboutsummaryrefslogtreecommitdiff
path: root/syrette_macros/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'syrette_macros/src/lib.rs')
-rw-r--r--syrette_macros/src/lib.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/syrette_macros/src/lib.rs b/syrette_macros/src/lib.rs
index 3fd8a59..faf338c 100644
--- a/syrette_macros/src/lib.rs
+++ b/syrette_macros/src/lib.rs
@@ -141,6 +141,30 @@ fn get_dependency_types(item_impl: &ItemImpl) -> Vec<Type>
);
}
+/// Makes a struct injectable. Therefore usable with `DIContainer`.
+///
+/// # Arguments
+///
+/// * A interface trait the struct implements.
+///
+/// # Examples
+/// ```
+/// trait IConfigReader
+/// {
+/// fn read_config() -> Config;
+/// }
+///
+/// struct ConfigReader {}
+///
+/// #[injectable(IConfigReader)]
+/// impl IConfigReader for ConfigReader
+/// {
+/// fn read_config() -> Config
+/// {
+/// // Stuff here
+/// }
+/// }
+/// ```
#[proc_macro_attribute]
pub fn injectable(args_stream: TokenStream, impl_stream: TokenStream) -> TokenStream
{
@@ -205,6 +229,7 @@ pub fn injectable(args_stream: TokenStream, impl_stream: TokenStream) -> TokenSt
.into()
}
+#[doc(hidden)]
#[proc_macro]
pub fn castable_to(input: TokenStream) -> TokenStream
{