From 262732c34c75141b20dee946a63bbae69cd43c71 Mon Sep 17 00:00:00 2001 From: hasezoey Date: Thu, 2 Nov 2023 16:27:13 +0100 Subject: [PATCH] refactor(code): build_table_fns: reduce clutter with "async" feature --- src/code.rs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/code.rs b/src/code.rs index ce685da6..0de29b62 100644 --- a/src/code.rs +++ b/src/code.rs @@ -420,22 +420,16 @@ fn build_table_fns( // template variables let table_name = table.name.to_string(); - #[cfg(feature = "async")] - let async_keyword = if table_options.get_async() { - " async" - } else { - "" - }; - #[cfg(not(feature = "async"))] - let async_keyword = ""; - #[cfg(feature = "async")] - let await_keyword = if table_options.get_async() { - ".await" - } else { - "" + #[allow(unused_labels)] // label is only used if feature is enabled + let (async_keyword, await_keyword) = 'async_block: { + #[cfg(feature = "async")] + if table_options.get_async() { + break 'async_block (" async", ".await"); + } + + ("", "") }; - #[cfg(not(feature = "async"))] - let await_keyword = ""; + let struct_name = &table.struct_name; let schema_path = &config.schema_path; let create_struct_identifier = &create_struct.identifier;