diff options
author | HampusM <hampus@hampusmat.com> | 2022-08-28 13:24:39 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2022-08-28 13:37:14 +0200 |
commit | f91c4ce73786a69e4ec72f69ef4d9d5f03ac5886 (patch) | |
tree | 6ac016e731eaf7e6fabdbcf12b84852cbc5af475 /macros/src | |
parent | dd6ae0c8643f08114469ccff66615b45ccf5e13e (diff) |
style: add rustfmt config options
Diffstat (limited to 'macros/src')
-rw-r--r-- | macros/src/injectable_impl.rs | 3 | ||||
-rw-r--r-- | macros/src/lib.rs | 33 | ||||
-rw-r--r-- | macros/src/libs/intertrait_macros/gen_caster.rs | 7 |
3 files changed, 19 insertions, 24 deletions
diff --git a/macros/src/injectable_impl.rs b/macros/src/injectable_impl.rs index 6edcab3..990b148 100644 --- a/macros/src/injectable_impl.rs +++ b/macros/src/injectable_impl.rs @@ -2,8 +2,7 @@ use std::error::Error; use quote::{format_ident, quote, ToTokens}; use syn::parse::{Parse, ParseStream}; -use syn::Generics; -use syn::{parse_str, ExprMethodCall, FnArg, ItemImpl, Type}; +use syn::{parse_str, ExprMethodCall, FnArg, Generics, ItemImpl, Type}; use crate::dependency::Dependency; use crate::util::item_impl::find_impl_method_by_name_mut; diff --git a/macros/src/lib.rs b/macros/src/lib.rs index c7157c8..6e3fc0a 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -29,7 +29,8 @@ use libs::intertrait_macros::gen_caster::generate_caster; /// * (Zero or more) Flags wrapped in curly braces. Like `{ a = true, b = false }` /// /// # Flags -/// - `no_doc_hidden` - Don't hide the impl of the [`Injectable`] trait from documentation. +/// - `no_doc_hidden` - Don't hide the impl of the [`Injectable`] trait from +/// documentation. /// /// # Panics /// If the attributed item is not a impl. @@ -68,14 +69,15 @@ use libs::intertrait_macros::gen_caster::generate_caster; /// impl Knight /// { /// pub fn new( -/// #[named("tough")] -/// tough_armor: TransientPtr<dyn IArmor>, +/// #[named("tough")] tough_armor: TransientPtr<dyn IArmor>, /// -/// #[named("light")] -/// light_armor: TransientPtr<dyn IArmor> +/// #[named("light")] light_armor: TransientPtr<dyn IArmor>, /// ) -> Self /// { -/// Self { tough_armor, light_armor } +/// Self { +/// tough_armor, +/// light_armor, +/// } /// } /// } /// # @@ -145,8 +147,8 @@ pub fn injectable(args_stream: TokenStream, impl_stream: TokenStream) -> TokenSt /// ``` /// use std::collections::HashMap; /// -/// use syrette::interfaces::factory::IFactory; /// use syrette::factory; +/// use syrette::interfaces::factory::IFactory; /// /// enum ConfigValue /// { @@ -161,7 +163,8 @@ pub fn injectable(args_stream: TokenStream, impl_stream: TokenStream) -> TokenSt /// fn configure(&self, key: String, value: ConfigValue); /// } /// -/// struct Configurator { +/// struct Configurator +/// { /// config: HashMap<String, ConfigValue>, /// } /// @@ -171,11 +174,10 @@ pub fn injectable(args_stream: TokenStream, impl_stream: TokenStream) -> TokenSt /// { /// Self { /// config: HashMap::from( -/// keys -/// .iter() +/// keys.iter() /// .map(|key| (key.clone(), ConfigValue::None)) -/// .collect::<HashMap<_, _>>() -/// ) +/// .collect::<HashMap<_, _>>(), +/// ), /// } /// } /// } @@ -226,7 +228,6 @@ pub fn factory(_: TokenStream, type_alias_stream: TokenStream) -> TokenStream /// /// # Arguments /// {Implementation} -> {Interface} -/// #[proc_macro] pub fn declare_interface(input: TokenStream) -> TokenStream { @@ -265,11 +266,9 @@ pub fn declare_interface(input: TokenStream) -> TokenStream /// impl Ninja /// { /// pub fn new( -/// #[syrette::named("strong")] -/// strong_weapon: TransientPtr<dyn IWeapon>, +/// #[syrette::named("strong")] strong_weapon: TransientPtr<dyn IWeapon>, /// -/// #[syrette::named("weak")] -/// weak_weapon: TransientPtr<dyn IWeapon>, +/// #[syrette::named("weak")] weak_weapon: TransientPtr<dyn IWeapon>, /// ) -> Self /// { /// Self { diff --git a/macros/src/libs/intertrait_macros/gen_caster.rs b/macros/src/libs/intertrait_macros/gen_caster.rs index d77262a..9bac09e 100644 --- a/macros/src/libs/intertrait_macros/gen_caster.rs +++ b/macros/src/libs/intertrait_macros/gen_caster.rs @@ -13,11 +13,8 @@ */ use std::str::from_utf8; -use proc_macro2::Ident; -use proc_macro2::TokenStream; -use quote::format_ident; -use quote::quote; -use quote::ToTokens; +use proc_macro2::{Ident, TokenStream}; +use quote::{format_ident, quote, ToTokens}; use uuid::adapter::Simple; use uuid::Uuid; |