Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 37b6a59

Browse files
plaferbobbinth
authored andcommitted
Derive PartialEq, Eq for ExecutionError (0xMiden#1145)
* Derive `PartialEq, Eq` for `ExecutionError` * clippy
1 parent 4e5c9b6 commit 37b6a59

12 files changed

Lines changed: 17 additions & 28 deletions

File tree

assembly/src/ast/imports.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ impl ModuleImports {
9595
/// Look up the actual procedure name and module path associated with the given [ProcedureId],
9696
/// if that procedure was imported and invoked in the current module.
9797
pub fn get_procedure_info(&self, id: &ProcedureId) -> Option<(&ProcedureName, &LibraryPath)> {
98-
self.invoked_procs.get(id).map(|(name, path)| (name, path))
98+
self.invoked_procs
99+
.get(id)
100+
.map(|invoked_proc| (&invoked_proc.0, &invoked_proc.1))
99101
}
100102

101103
/// Look up the procedure name associated with the given [ProcedureId],

core/src/program/blocks/call_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::utils::to_hex;
1414
/// > hash(fn_hash || padding, domain=SYSCALL_DOMAIN) # when a syscall is used
1515
///
1616
/// Where `fn_hash` is 4 field elements (256 bits), and `padding` is 4 ZERO elements (256 bits).
17-
#[derive(Clone, Debug)]
17+
#[derive(Clone, Debug, PartialEq, Eq)]
1818
pub struct Call {
1919
hash: Digest,
2020
fn_hash: Digest,

core/src/program/blocks/dyn_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const DYN_CONSTANT: Digest = Digest::new([
2424
/// affect the representation of the Dyn block. Therefore all Dyn blocks are represented by the same
2525
/// constant (rather than by unique hashes), which is computed as an RPO hash of two empty words
2626
/// ([ZERO, ZERO, ZERO, ZERO]) with a domain value of `DYN_DOMAIN`.
27-
#[derive(Clone, Debug)]
27+
#[derive(Clone, Debug, PartialEq, Eq)]
2828
pub struct Dyn {}
2929

3030
impl Dyn {

core/src/program/blocks/join_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::{fmt, hasher, Box, CodeBlock, Digest, Felt, Operation};
1111
/// > hash(left_block_hash || right_block_hash, domain=JOIN_DOMAIN)
1212
///
1313
/// Where `left_block_hash` and `right_block_hash` are 4 field elements (256 bits) each.
14-
#[derive(Clone, Debug)]
14+
#[derive(Clone, Debug, PartialEq, Eq)]
1515
pub struct Join {
1616
body: Box<[CodeBlock; 2]>,
1717
hash: Digest,

core/src/program/blocks/loop_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use super::{fmt, hasher, Box, CodeBlock, Digest, Felt, Operation};
1212
/// > hash(body_hash || padding, domain=LOOP_DOMAIN)
1313
///
1414
/// Where `body_hash` is 4 field elements (256 bits), and `padding` is 4 ZERO elements (256 bits).
15-
#[derive(Clone, Debug)]
15+
#[derive(Clone, Debug, PartialEq, Eq)]
1616
pub struct Loop {
1717
body: Box<CodeBlock>,
1818
hash: Digest,

core/src/program/blocks/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub use split_block::Split;
2424
// PROGRAM BLOCK
2525
// ================================================================================================
2626
/// TODO: add comments
27-
#[derive(Clone, Debug)]
27+
#[derive(Clone, Debug, PartialEq, Eq)]
2828
pub enum CodeBlock {
2929
Span(Span),
3030
Join(Join),

core/src/program/blocks/proxy_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use super::{fmt, Digest};
88
/// of the program secret. Fails if executed.
99
///
1010
/// Hash of a proxy block is not computed but is rather defined at instantiation time.
11-
#[derive(Clone, Debug)]
11+
#[derive(Clone, Debug, PartialEq, Eq)]
1212
pub struct Proxy {
1313
hash: Digest,
1414
}

core/src/program/blocks/span_block.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const MAX_OPS_PER_BATCH: usize = GROUP_SIZE * BATCH_SIZE;
4545
///
4646
/// Where `batches` is the concatenation of each `batch` in the span, and each batch is 8 field
4747
/// elements (512 bits).
48-
#[derive(Clone, Debug)]
48+
#[derive(Clone, Debug, PartialEq, Eq)]
4949
pub struct Span {
5050
op_batches: Vec<OpBatch>,
5151
hash: Digest,
@@ -170,7 +170,7 @@ impl fmt::Display for Span {
170170
///
171171
/// An operation batch consists of up to 8 operation groups, with each group containing up to 9
172172
/// operations or a single immediate value.
173-
#[derive(Clone, Debug)]
173+
#[derive(Clone, Debug, PartialEq, Eq)]
174174
pub struct OpBatch {
175175
ops: Vec<Operation>,
176176
groups: [Felt; BATCH_SIZE],

core/src/program/blocks/split_block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use super::{fmt, hasher, Box, CodeBlock, Digest, Felt, Operation};
1212
/// > hash(true_branch_hash || false_branch_hash, domain=SPLIT_DOMAIN)
1313
///
1414
/// Where `true_branch_hash` and `false_branch_hash` are 4 field elements (256 bits) each.
15-
#[derive(Clone, Debug)]
15+
#[derive(Clone, Debug, PartialEq, Eq)]
1616
pub struct Split {
1717
branches: Box<[CodeBlock; 2]>,
1818
hash: Digest,

core/src/stack/inputs.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,8 @@ impl StackInputs {
2929
where
3030
I: IntoIterator<Item = u64>,
3131
{
32-
iter.into_iter()
33-
.map(|v| {
34-
Felt::try_from(v).map_err(|_| {
35-
InputError::NotFieldElement(v, "the provided value isn't a valid field element")
36-
})
37-
})
38-
.collect::<Result<Vec<_>, _>>()
39-
.map(Self::new)
32+
let values: Vec<Felt> = iter.into_iter().map(Felt::from).collect();
33+
Ok(Self::new(values))
4034
}
4135

4236
// PUBLIC ACCESSORS

0 commit comments

Comments
 (0)