From 6e31d8f9e46fece348f329763b39b9c6f2741c07 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 28 Aug 2022 13:50:15 +0200 Subject: docs: improve & add examples --- src/lib.rs | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index cac6ffe..8908143 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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... /// } -- cgit v1.2.3-18-g5258