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 --- macros/src/lib.rs | 77 ++++++++++++++++++++++--------------------------------- 1 file changed, 30 insertions(+), 47 deletions(-) (limited to 'macros/src') diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 6e3fc0a..eb3a2be 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -70,7 +70,6 @@ use libs::intertrait_macros::gen_caster::generate_caster; /// { /// pub fn new( /// #[named("tough")] tough_armor: TransientPtr, -/// /// #[named("light")] light_armor: TransientPtr, /// ) -> Self /// { @@ -145,51 +144,23 @@ pub fn injectable(args_stream: TokenStream, impl_stream: TokenStream) -> TokenSt /// /// # Examples /// ``` -/// use std::collections::HashMap; -/// -/// use syrette::factory; -/// use syrette::interfaces::factory::IFactory; -/// -/// enum ConfigValue -/// { -/// String(String), -/// Bool(bool), -/// Int(i32), -/// None, -/// } -/// -/// trait IConfigurator -/// { -/// fn configure(&self, key: String, value: ConfigValue); -/// } -/// -/// struct Configurator -/// { -/// config: HashMap, -/// } -/// -/// impl Configurator -/// { -/// fn new(keys: Vec) -> Self -/// { -/// Self { -/// config: HashMap::from( -/// keys.iter() -/// .map(|key| (key.clone(), ConfigValue::None)) -/// .collect::>(), -/// ), -/// } -/// } -/// } -/// -/// impl IConfigurator for Configurator -/// { -/// fn configure(&self, key: String, value: ConfigValue) -/// { -/// // ... -/// } -/// } -/// +/// # use syrette::factory; +/// # use syrette::interfaces::factory::IFactory; +/// # +/// # trait IConfigurator {} +/// # +/// # struct Configurator {} +/// # +/// # impl Configurator +/// # { +/// # fn new() -> Self +/// # { +/// # Self {} +/// # } +/// # } +/// # +/// # impl IConfigurator for Configurator {} +/// # /// #[factory] /// type IConfiguratorFactory = dyn IFactory<(Vec,), dyn IConfigurator>; /// ``` @@ -228,6 +199,19 @@ pub fn factory(_: TokenStream, type_alias_stream: TokenStream) -> TokenStream /// /// # Arguments /// {Implementation} -> {Interface} +/// +/// # Examples +/// ``` +/// # use syrette::declare_interface; +/// # +/// # trait INinja {} +/// # +/// # struct Ninja {} +/// # +/// # impl INinja for Ninja {} +/// # +/// declare_interface!(Ninja -> INinja); +/// ``` #[proc_macro] pub fn declare_interface(input: TokenStream) -> TokenStream { @@ -267,7 +251,6 @@ pub fn declare_interface(input: TokenStream) -> TokenStream /// { /// pub fn new( /// #[syrette::named("strong")] strong_weapon: TransientPtr, -/// /// #[syrette::named("weak")] weak_weapon: TransientPtr, /// ) -> Self /// { -- cgit v1.2.3-18-g5258