Skip to content

Commit

Permalink
refactor(code): build_table_fns: reduce clutter with "async" feature
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Nov 2, 2023
1 parent 3e54f54 commit 262732c
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 262732c

Please sign in to comment.