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 /macros/src | |
parent | f91c4ce73786a69e4ec72f69ef4d9d5f03ac5886 (diff) |
docs: improve & add examples
Diffstat (limited to 'macros/src')
-rw-r--r-- | macros/src/lib.rs | 77 |
1 files changed, 30 insertions, 47 deletions
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<dyn IArmor>, -/// /// #[named("light")] light_armor: TransientPtr<dyn IArmor>, /// ) -> 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<String, ConfigValue>, -/// } -/// -/// impl Configurator -/// { -/// fn new(keys: Vec<String>) -> Self -/// { -/// Self { -/// config: HashMap::from( -/// keys.iter() -/// .map(|key| (key.clone(), ConfigValue::None)) -/// .collect::<HashMap<_, _>>(), -/// ), -/// } -/// } -/// } -/// -/// 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<String>,), 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<dyn IWeapon>, -/// /// #[syrette::named("weak")] weak_weapon: TransientPtr<dyn IWeapon>, /// ) -> Self /// { |