diff --git a/substrate/frame/support/src/storage/transactional.rs b/substrate/frame/support/src/storage/transactional.rs index b02552bdb0..d1bdb30af9 100644 --- a/substrate/frame/support/src/storage/transactional.rs +++ b/substrate/frame/support/src/storage/transactional.rs @@ -101,9 +101,10 @@ pub fn is_transactional() -> bool { /// error. /// /// Commits happen to the parent transaction. -pub fn with_transaction(f: impl FnOnce() -> TransactionOutcome>) -> Result +pub fn with_transaction(f: F) -> Result where E: From, + F: FnOnce() -> TransactionOutcome>, { // This needs to happen before `start_transaction` below. // Otherwise we may rollback the increase, then decrease as the guard goes out of scope @@ -129,7 +130,10 @@ where /// This is mostly for backwards compatibility before there was a transactional layer limit. /// It is recommended to only use [`with_transaction`] to avoid users from generating too many /// transactional layers. -pub fn with_transaction_unchecked(f: impl FnOnce() -> TransactionOutcome) -> R { +pub fn with_transaction_unchecked(f: F) -> R +where + F: FnOnce() -> TransactionOutcome, +{ // This needs to happen before `start_transaction` below. // Otherwise we may rollback the increase, then decrease as the guard goes out of scope // and then end in some bad state. @@ -163,9 +167,10 @@ pub fn with_transaction_unchecked(f: impl FnOnce() -> TransactionOutcome) /// This is the same as `with_transaction`, but assuming that any function returning /// an `Err` should rollback, and any function returning `Ok` should commit. This /// provides a cleaner API to the developer who wants this behavior. -pub fn with_storage_layer(f: impl FnOnce() -> Result) -> Result +pub fn with_storage_layer(f: F) -> Result where E: From, + F: FnOnce() -> Result, { with_transaction(|| { let r = f(); @@ -181,9 +186,10 @@ where /// /// If we are already in a storage layer, we just execute the provided closure. /// If we are not, we execute the closure within a [`with_storage_layer`]. -pub fn in_storage_layer(f: impl FnOnce() -> Result) -> Result +pub fn in_storage_layer(f: F) -> Result where E: From, + F: FnOnce() -> Result, { if is_transactional() { f()