-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1831 from multiversx/pass-value
unified syntax - PassValue
- Loading branch information
Showing
4 changed files
with
35 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
framework/base/src/types/interaction/result_handlers/pass_value.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::types::{RHListItem, RHListItemExec, TxEnv}; | ||
|
||
/// Simply passes a value to the result. | ||
/// | ||
/// The value is constant with respect to the tx, will always be returned, irrespective of the tx execution. | ||
/// | ||
/// It is especially useful in multi-calls, since it can pass context from the setup section to the result processing section. | ||
pub struct PassValue<T>(pub T); | ||
|
||
impl<Env, Original, T> RHListItem<Env, Original> for PassValue<T> | ||
where | ||
Env: TxEnv, | ||
{ | ||
type Returns = T; | ||
} | ||
|
||
impl<RawResult, Env, Original, T> RHListItemExec<RawResult, Env, Original> for PassValue<T> | ||
where | ||
Env: TxEnv, | ||
{ | ||
fn item_process_result(self, _raw_result: &RawResult) -> T { | ||
self.0 | ||
} | ||
} |