remove code smell
This commit is contained in:
parent
4039b109c4
commit
c06df53b6a
3 changed files with 25 additions and 25 deletions
|
@ -99,7 +99,7 @@ impl<T: Field> Value<T> {
|
|||
} else {
|
||||
let a = a
|
||||
.into_iter()
|
||||
.map(|val| val.check((*array_type.ty).clone()))
|
||||
.map(|val| val.check(*array_type.ty.clone()))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(CheckedValue::Array(a))
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ impl<T: From<usize> + PartialEq + Clone> Decode<T> for CheckedValue<T> {
|
|||
}
|
||||
Type::Array(array_type) => CheckedValue::Array(
|
||||
raw.chunks(array_type.ty.get_primitive_count())
|
||||
.map(|c| CheckedValue::decode(c.to_vec(), (*array_type.ty).clone()))
|
||||
.map(|c| CheckedValue::decode(c.to_vec(), *array_type.ty.clone()))
|
||||
.collect(),
|
||||
),
|
||||
Type::Struct(members) => CheckedValue::Struct(
|
||||
|
@ -412,7 +412,7 @@ mod tests {
|
|||
s,
|
||||
vec![Type::Struct(vec![StructMember::new(
|
||||
"a".into(),
|
||||
box Type::FieldElement
|
||||
Type::FieldElement
|
||||
)])]
|
||||
)
|
||||
.unwrap(),
|
||||
|
@ -429,7 +429,7 @@ mod tests {
|
|||
s,
|
||||
vec![Type::Struct(vec![StructMember::new(
|
||||
"a".into(),
|
||||
box Type::FieldElement
|
||||
Type::FieldElement
|
||||
)])]
|
||||
)
|
||||
.unwrap_err(),
|
||||
|
@ -442,7 +442,7 @@ mod tests {
|
|||
s,
|
||||
vec![Type::Struct(vec![StructMember::new(
|
||||
"a".into(),
|
||||
box Type::FieldElement
|
||||
Type::FieldElement
|
||||
)])]
|
||||
)
|
||||
.unwrap_err(),
|
||||
|
@ -455,7 +455,7 @@ mod tests {
|
|||
s,
|
||||
vec![Type::Struct(vec![StructMember::new(
|
||||
"a".into(),
|
||||
box Type::FieldElement
|
||||
Type::FieldElement
|
||||
)])]
|
||||
)
|
||||
.unwrap_err(),
|
||||
|
|
|
@ -285,7 +285,7 @@ impl<'ast> Checker<'ast> {
|
|||
Ok(Type::Struct(
|
||||
fields
|
||||
.iter()
|
||||
.map(|f| StructMember::new(f.0.clone(), box f.1.clone()))
|
||||
.map(|f| StructMember::new(f.0.clone(), f.1.clone()))
|
||||
.collect(),
|
||||
))
|
||||
}
|
||||
|
@ -1308,7 +1308,7 @@ impl<'ast> Checker<'ast> {
|
|||
},
|
||||
arguments_checked,
|
||||
)
|
||||
.annotate((*array_type.ty).clone(), array_type.size.clone())
|
||||
.annotate(*array_type.ty.clone(), array_type.size.clone())
|
||||
.into()),
|
||||
_ => unimplemented!(),
|
||||
},
|
||||
|
@ -1513,7 +1513,7 @@ impl<'ast> Checker<'ast> {
|
|||
Type::Array(array_type) => {
|
||||
Ok(ArrayExpressionInner::Select(box a, box i)
|
||||
.annotate(
|
||||
(*array_type.ty).clone(),
|
||||
*array_type.ty.clone(),
|
||||
array_type.size.clone(),
|
||||
)
|
||||
.into())
|
||||
|
@ -1543,7 +1543,7 @@ impl<'ast> Checker<'ast> {
|
|||
match e {
|
||||
TypedExpression::Struct(s) => {
|
||||
// check that the struct has that field and return the type if it does
|
||||
let ty = s.ty().iter().find(|m| m.id == id).map(|m| (*m.ty).clone());
|
||||
let ty = s.ty().iter().find(|m| m.id == id).map(|m| *m.ty.clone());
|
||||
|
||||
match ty {
|
||||
Some(ty) => match ty {
|
||||
|
@ -1555,7 +1555,7 @@ impl<'ast> Checker<'ast> {
|
|||
}
|
||||
Type::Array(array_type) => {
|
||||
Ok(ArrayExpressionInner::Member(box s.clone(), id.to_string())
|
||||
.annotate((*array_type.ty).clone(), array_type.size)
|
||||
.annotate(*array_type.ty.clone(), array_type.size)
|
||||
.into())
|
||||
}
|
||||
Type::Struct(members) => {
|
||||
|
@ -3374,8 +3374,8 @@ mod tests {
|
|||
.mock();
|
||||
|
||||
let expected_type = Type::Struct(vec![
|
||||
StructMember::new("foo".to_string(), box Type::FieldElement),
|
||||
StructMember::new("bar".to_string(), box Type::Boolean),
|
||||
StructMember::new("foo".to_string(), Type::FieldElement),
|
||||
StructMember::new("bar".to_string(), Type::Boolean),
|
||||
]);
|
||||
|
||||
assert_eq!(
|
||||
|
@ -3514,9 +3514,9 @@ mod tests {
|
|||
.unwrap(),
|
||||
&Type::Struct(vec![StructMember::new(
|
||||
"foo".to_string(),
|
||||
box Type::Struct(vec![StructMember::new(
|
||||
Type::Struct(vec![StructMember::new(
|
||||
"foo".to_string(),
|
||||
box Type::FieldElement
|
||||
Type::FieldElement
|
||||
)])
|
||||
)])
|
||||
);
|
||||
|
@ -3662,7 +3662,7 @@ mod tests {
|
|||
),
|
||||
Ok(Type::Struct(vec![StructMember::new(
|
||||
"foo".to_string(),
|
||||
box Type::FieldElement
|
||||
Type::FieldElement
|
||||
)]))
|
||||
);
|
||||
|
||||
|
@ -3712,7 +3712,7 @@ mod tests {
|
|||
"a".into(),
|
||||
Type::Struct(vec![StructMember::new(
|
||||
"foo".to_string(),
|
||||
box Type::FieldElement
|
||||
Type::FieldElement
|
||||
)])
|
||||
),
|
||||
private: true
|
||||
|
@ -3771,7 +3771,7 @@ mod tests {
|
|||
"a".into(),
|
||||
Type::Struct(vec![StructMember::new(
|
||||
"foo".to_string(),
|
||||
box Type::FieldElement
|
||||
Type::FieldElement
|
||||
)])
|
||||
)))
|
||||
);
|
||||
|
@ -3841,7 +3841,7 @@ mod tests {
|
|||
.into()])
|
||||
.annotate(vec![StructMember::new(
|
||||
"foo".to_string(),
|
||||
box Type::FieldElement
|
||||
Type::FieldElement
|
||||
)]),
|
||||
"foo".to_string()
|
||||
)
|
||||
|
@ -3968,8 +3968,8 @@ mod tests {
|
|||
BooleanExpression::Value(true).into()
|
||||
])
|
||||
.annotate(vec![
|
||||
StructMember::new("foo".to_string(), box Type::FieldElement),
|
||||
StructMember::new("bar".to_string(), box Type::Boolean)
|
||||
StructMember::new("foo".to_string(), Type::FieldElement),
|
||||
StructMember::new("bar".to_string(), Type::Boolean)
|
||||
])
|
||||
.into())
|
||||
);
|
||||
|
@ -4018,8 +4018,8 @@ mod tests {
|
|||
BooleanExpression::Value(true).into()
|
||||
])
|
||||
.annotate(vec![
|
||||
StructMember::new("foo".to_string(), box Type::FieldElement),
|
||||
StructMember::new("bar".to_string(), box Type::Boolean)
|
||||
StructMember::new("foo".to_string(), Type::FieldElement),
|
||||
StructMember::new("bar".to_string(), Type::Boolean)
|
||||
])
|
||||
.into())
|
||||
);
|
||||
|
|
|
@ -39,8 +39,8 @@ impl ArrayType {
|
|||
}
|
||||
|
||||
impl StructMember {
|
||||
pub fn new(id: String, ty: Box<Type>) -> Self {
|
||||
StructMember { id, ty }
|
||||
pub fn new(id: String, ty: Type) -> Self {
|
||||
StructMember { id, ty: Box::new(ty) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue