#[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 } }}; }