Skip to content

Commit

Permalink
alternate is_ and as_ methods
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulmth committed Aug 1, 2023
1 parent f65846d commit 2f49f19
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions sdk/src/types/block/context_input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@ impl ContextInput {
matches!(self, Self::Commitment(_))
}

/// Checks whether the context input is a [`BlockIssuanceCreditContextInput`].
pub fn is_block_issuance_credit(&self) -> bool {
matches!(self, Self::BlockIssuanceCredit(_))
}

/// Checks whether the context input is a [`RewardContextInput`].
pub fn is_reward(&self) -> bool {
matches!(self, Self::Reward(_))
}

/// Gets the input as an actual [`CommitmentContextInput`].
/// PANIC: do not call on a non-commitment context input.
pub fn as_commitment(&self) -> &CommitmentContextInput {
Expand All @@ -74,6 +64,12 @@ impl ContextInput {
panic!("invalid downcast of non-CommitmentContextInput");
}
}

/// Checks whether the context input is a [`BlockIssuanceCreditContextInput`].
pub fn is_block_issuance_credit(&self) -> bool {
matches!(self, Self::BlockIssuanceCredit(_))
}

/// Gets the input as an actual [`BlockIssuanceCreditContextInput`].
/// PANIC: do not call on a non-block-issuance-credit context input.
pub fn as_block_issuance_credit(&self) -> &BlockIssuanceCreditContextInput {
Expand All @@ -84,6 +80,11 @@ impl ContextInput {
}
}

/// Checks whether the context input is a [`RewardContextInput`].
pub fn is_reward(&self) -> bool {
matches!(self, Self::Reward(_))
}

/// Gets the input as an actual [`RewardContextInput`].
/// PANIC: do not call on a non-reward context input.
pub fn as_reward(&self) -> &RewardContextInput {
Expand Down

0 comments on commit 2f49f19

Please sign in to comment.