use ref of transaction

This commit is contained in:
GW_MC
2025-12-07 21:35:10 +08:00
parent 6a88e401f6
commit 6cd37d6758

View File

@@ -1,12 +1,12 @@
#[macro_export]
macro_rules! with_conn {
// Usage: with_conn!(connection, tx_option, ident, |conn|-> { ... })
// Usage: with_conn!(&connection, tx_option, ident, |conn|-> { ... })
($conn:expr, $tx:expr, $ident:ident, $body:block) => {{
if let Some(t) = $tx {
if let Some(t) = &$tx {
let $ident = t;
$body
} else {
let $ident = $conn;
let $ident = &$conn;
$body
}
}};