diff options
author | HampusM <hampus@hampusmat.com> | 2022-08-28 13:50:15 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-08-28 13:50:15 +0200 |
commit | 6e31d8f9e46fece348f329763b39b9c6f2741c07 (patch) | |
tree | 1993cd9af613ffe7dcb9a88fcca7f0dbfb28b67b /src | |
parent | f91c4ce73786a69e4ec72f69ef4d9d5f03ac5886 (diff) |
docs: improve & add examples
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -38,6 +38,30 @@ mod provider; /// /// # Arguments /// {interface} => {implementation}, {DI container variable name} +/// +/// # Examples +/// ``` +/// # use syrette::{di_container_bind, DIContainer, injectable}; +/// # +/// # trait INinja {} +/// # +/// # struct Ninja {} +/// # +/// # #[injectable] +/// # impl Ninja +/// # { +/// # fn new() -> Self +/// # { +/// # Self {} +/// # } +/// # } +/// # +/// # impl INinja for Ninja {} +/// # +/// let mut di_container = DIContainer::new(); +/// +/// di_container_bind!(INinja => Ninja, di_container); +/// ``` #[macro_export] macro_rules! di_container_bind { ($interface: path => $implementation: ty, $di_container: ident) => { @@ -62,8 +86,8 @@ macro_rules! di_container_bind { /// /// # Examples /// ``` -/// use syrette::declare_default_factory; -/// +/// # use syrette::declare_default_factory; +/// # /// trait IParser /// { /// // Methods and etc here... @@ -75,8 +99,8 @@ macro_rules! di_container_bind { /// The expanded equivelent of this would be /// /// ``` -/// use syrette::declare_default_factory; -/// +/// # use syrette::declare_default_factory; +/// # /// trait IParser { /// // Methods and etc here... /// } |