* change impl FnOnce() to generic type + trait bound
with_transaction() function can not be used with explicit generic arguments because of this issue: https://github.com/rust-lang/rust/issues/83701
* make the same changes elsewhere
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>