From b4ddc1e626fbd11d784b442d246ddc5f54c35b51 Mon Sep 17 00:00:00 2001 From: HampusM Date: Fri, 4 Aug 2023 17:38:00 +0200 Subject: refactor!: rename the async flag of the declare_interface macro BREAKING CHANGE: The flag 'async' of the declare_interface macro has been renamed to 'threadsafe_sharable'. The reason being that the name 'async' was an outright lie. The new name describes exactly what the flag enables --- macros/src/lib.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'macros/src/lib.rs') diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 80274fd..b261974 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -220,14 +220,14 @@ pub fn injectable(args_stream: TokenStream, input_stream: TokenStream) -> TokenS }); let maybe_decl_interface = if let Some(interface) = opt_interface { - let async_flag = if is_async { - quote! {, async = true} + let threadsafe_sharable_flag = if is_async { + quote! { , threadsafe_sharable = true } } else { quote! {} }; quote! { - syrette::declare_interface!(#self_type -> #interface #async_flag); + syrette::declare_interface!(#self_type -> #interface #threadsafe_sharable_flag); } } else { quote! {} @@ -443,7 +443,8 @@ pub fn declare_default_factory(args_stream: TokenStream) -> TokenStream /// * (Zero or more) Flags. Like `a = true, b = false` /// /// # Flags -/// - `async` - Mark as async. +/// - `threadsafe_sharable` - Enables the use of thread-safe shared instances of the +/// implementation accessed with the interface. /// /// # Examples /// ``` @@ -468,9 +469,11 @@ pub fn declare_interface(input: TokenStream) -> TokenStream flags, } = parse(input).unwrap_or_abort(); - let opt_async_flag = flags.iter().find(|flag| flag.name() == "async"); + let threadsafe_sharable_flag = flags + .iter() + .find(|flag| flag.name() == "threadsafe_sharable"); - let is_async = opt_async_flag + let is_async = threadsafe_sharable_flag .map_or_else(|| Ok(false), MacroFlag::get_bool) .unwrap_or_abort(); -- cgit v1.2.3-18-g5258