Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
feat(acir): add method on Circuit to return assert message (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench authored Sep 17, 2023
1 parent de17b7c commit ee18cde
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions acir/src/circuit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ pub struct Circuit {
pub assert_messages: Vec<(OpcodeLocation, String)>,
}

impl Circuit {
/// Returns the assert message associated with the provided [`OpcodeLocation`].
/// Returns `None` if no such assert message exists.
pub fn get_assert_message(&self, opcode_location: OpcodeLocation) -> Option<&str> {
self.assert_messages
.iter()
.find(|(loc, _)| *loc == opcode_location)
.map(|(_, message)| message.as_str())
}
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
/// Opcodes are locatable so that callers can
/// map opcodes to debug information related to their context.
Expand Down

0 comments on commit ee18cde

Please sign in to comment.