diff --git a/compiler/src/import/parser/import_parser.rs b/compiler/src/import/parser/import_parser.rs index 5bf3386498..8ab7f0f3d8 100644 --- a/compiler/src/import/parser/import_parser.rs +++ b/compiler/src/import/parser/import_parser.rs @@ -41,7 +41,7 @@ impl ImportParser { let _res = self.core_packages.push(package.clone()); } - pub fn get_import(&self, file_name: &String) -> Option<&Program> { + pub fn get_import(&self, file_name: &str) -> Option<&Program> { self.imports.get(file_name) } diff --git a/compiler/src/program/program.rs b/compiler/src/program/program.rs index 24981cc59f..8e87702ab8 100644 --- a/compiler/src/program/program.rs +++ b/compiler/src/program/program.rs @@ -39,7 +39,7 @@ pub fn new_scope(outer: String, inner: String) -> String { format!("{}_{}", outer, inner) } -pub fn is_in_scope(current_scope: &String, desired_scope: &String) -> bool { +pub fn is_in_scope(current_scope: &str, desired_scope: &str) -> bool { current_scope.ends_with(desired_scope) } @@ -52,11 +52,11 @@ impl> ConstrainedProgram { self.identifiers.insert(name, value); } - pub(crate) fn get(&self, name: &String) -> Option<&ConstrainedValue> { + pub(crate) fn get(&self, name: &str) -> Option<&ConstrainedValue> { self.identifiers.get(name) } - pub(crate) fn get_mut(&mut self, name: &String) -> Option<&mut ConstrainedValue> { + pub(crate) fn get_mut(&mut self, name: &str) -> Option<&mut ConstrainedValue> { self.identifiers.get_mut(name) } } diff --git a/leo/synthesizer/serialized_circuit.rs b/leo/synthesizer/serialized_circuit.rs index ae1293d191..96dd62849e 100644 --- a/leo/synthesizer/serialized_circuit.rs +++ b/leo/synthesizer/serialized_circuit.rs @@ -57,7 +57,7 @@ impl From> for SerializedCircuit { let num_constraints = synthesizer.num_constraints(); // Serialize assignments - fn get_serialized_assignments(assignments: &Vec) -> Vec { + fn get_serialized_assignments(assignments: &[E::Fr]) -> Vec { let mut serialized = vec![]; for assignment in assignments { @@ -74,7 +74,7 @@ impl From> for SerializedCircuit { // Serialize constraints fn get_serialized_constraints( - constraints: &Vec<(E::Fr, Index)>, + constraints: &[(E::Fr, Index)], ) -> Vec<(SerializedField, SerializedIndex)> { let mut serialized = vec![]; @@ -128,7 +128,7 @@ impl TryFrom for CircuitSynthesizer { fn try_from(serialized: SerializedCircuit) -> Result, Self::Error> { // Deserialize assignments fn get_deserialized_assignments( - assignments: &Vec, + assignments: &[SerializedField], ) -> Result::Fr>, FieldError> { let mut deserialized = vec![]; @@ -146,7 +146,7 @@ impl TryFrom for CircuitSynthesizer { // Deserialize constraints fn get_deserialized_constraints( - constraints: &Vec<(SerializedField, SerializedIndex)>, + constraints: &[(SerializedField, SerializedIndex)], ) -> Result::Fr, Index)>, FieldError> { let mut deserialized = vec![]; diff --git a/typed/src/input/program_input/main_input.rs b/typed/src/input/program_input/main_input.rs index 90c2b1a940..6071305eec 100644 --- a/typed/src/input/program_input/main_input.rs +++ b/typed/src/input/program_input/main_input.rs @@ -61,7 +61,7 @@ impl MainInput { } /// Returns an `Option` of the main function input at `name` - pub fn get(&self, name: &String) -> Option> { + pub fn get(&self, name: &str) -> Option> { self.input.get(name).map(|input| input.clone()) } } diff --git a/typed/src/types/type_.rs b/typed/src/types/type_.rs index 8754232526..42b4eda439 100644 --- a/typed/src/types/type_.rs +++ b/typed/src/types/type_.rs @@ -78,7 +78,7 @@ impl Type { type_1_expanded.eq(&type_2_expanded) && dimensions_1_expanded.eq(&dimensions_2_expanded) } - pub fn outer_dimension(&self, dimensions: &Vec) -> Self { + pub fn outer_dimension(&self, dimensions: &[usize]) -> Self { let type_ = self.clone(); if dimensions.len() > 1 { @@ -91,7 +91,7 @@ impl Type { type_ } - pub fn inner_dimension(&self, dimensions: &Vec) -> Self { + pub fn inner_dimension(&self, dimensions: &[usize]) -> Self { let type_ = self.clone(); if dimensions.len() > 1 { @@ -105,16 +105,16 @@ impl Type { } } -fn expand_array_type(type_: &Type, dimensions: &Vec) -> (Type, Vec) { +fn expand_array_type(type_: &Type, dimensions: &[usize]) -> (Type, Vec) { if let Type::Array(nested_type, nested_dimensions) = type_ { // Expand nested array type - let mut expanded_dimensions = dimensions.clone(); + let mut expanded_dimensions = dimensions.to_vec(); expanded_dimensions.append(&mut nested_dimensions.clone()); expand_array_type(nested_type, &expanded_dimensions) } else { // Array type is fully expanded - (type_.clone(), dimensions.clone()) + (type_.clone(), dimensions.to_vec()) } }