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