mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-27 03:21:49 +03:00
clippy: fix new_without_default
Signed-off-by: ljedrz <ljedrz@gmail.com>
This commit is contained in:
parent
80bb3033fd
commit
ffef5089f7
@ -21,7 +21,7 @@ use std::{collections::HashMap, env::current_dir};
|
||||
|
||||
/// Parses all relevant import files for a program.
|
||||
/// Stores compiled program structs.
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Default)]
|
||||
pub struct ImportParser {
|
||||
imports: HashMap<String, Program>,
|
||||
core_packages: Vec<Package>,
|
||||
@ -29,10 +29,7 @@ pub struct ImportParser {
|
||||
|
||||
impl ImportParser {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
imports: HashMap::new(),
|
||||
core_packages: vec![],
|
||||
}
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub(crate) fn insert_import(&mut self, file_name: String, program: Program) {
|
||||
|
@ -27,6 +27,14 @@ pub struct ConstrainedProgram<F: Field + PrimeField, G: GroupType<F>> {
|
||||
pub identifiers: HashMap<String, ConstrainedValue<F, G>>,
|
||||
}
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> Default for ConstrainedProgram<F, G> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
identifiers: HashMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_scope(outer: String, inner: String) -> String {
|
||||
format!("{}_{}", outer, inner)
|
||||
}
|
||||
@ -37,9 +45,7 @@ pub fn is_in_scope(current_scope: &String, desired_scope: &String) -> bool {
|
||||
|
||||
impl<F: Field + PrimeField, G: GroupType<F>> ConstrainedProgram<F, G> {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
identifiers: HashMap::new(),
|
||||
}
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub(crate) fn store(&mut self, name: String, value: ConstrainedValue<F, G>) {
|
||||
|
@ -21,6 +21,7 @@ use crate::{
|
||||
|
||||
use std::{collections::HashMap, convert::TryFrom, path::PathBuf};
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct InputPairs {
|
||||
/// Maps file names to input file pairs
|
||||
pub pairs: HashMap<String, InputPair>,
|
||||
@ -33,7 +34,7 @@ pub struct InputPair {
|
||||
|
||||
impl InputPairs {
|
||||
pub fn new() -> Self {
|
||||
Self { pairs: HashMap::new() }
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,12 +23,12 @@ use std::{fs::File, io::Write, path::PathBuf};
|
||||
|
||||
pub static GITIGNORE_FILENAME: &str = ".gitignore";
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, Default)]
|
||||
pub struct Gitignore;
|
||||
|
||||
impl Gitignore {
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn exists_at(path: &PathBuf) -> bool {
|
||||
|
@ -27,14 +27,20 @@ pub struct Input {
|
||||
program_state: ProgramState,
|
||||
}
|
||||
|
||||
impl Input {
|
||||
pub fn new() -> Self {
|
||||
impl Default for Input {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
name: "default".to_owned(),
|
||||
program_input: ProgramInput::new(),
|
||||
program_state: ProgramState::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Input {
|
||||
pub fn new() -> Self {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns an empty version of this struct with `None` values.
|
||||
/// Called during constraint synthesis to provide private input variables.
|
||||
|
@ -19,7 +19,7 @@ macro_rules! input_section_impl {
|
||||
($($name: ident), *) => ($(
|
||||
|
||||
/// An input section declared in an input file with `[$name]`
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq, Default)]
|
||||
pub struct $name {
|
||||
is_present: bool,
|
||||
values: HashMap<Parameter, Option<InputValue>>,
|
||||
@ -27,10 +27,7 @@ macro_rules! input_section_impl {
|
||||
|
||||
impl $name {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
is_present: false,
|
||||
values: HashMap::new(),
|
||||
}
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns an empty version of this struct with `None` values.
|
||||
|
@ -18,14 +18,14 @@ use crate::InputValue;
|
||||
use leo_input::{definitions::Definition, InputParserError};
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq, Default)]
|
||||
pub struct MainInput {
|
||||
input: HashMap<String, Option<InputValue>>,
|
||||
}
|
||||
|
||||
impl MainInput {
|
||||
pub fn new() -> Self {
|
||||
Self { input: HashMap::new() }
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns an empty version of this struct with `None` values.
|
||||
|
@ -20,7 +20,7 @@ use leo_input::{
|
||||
InputParserError,
|
||||
};
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq, Default)]
|
||||
pub struct ProgramInput {
|
||||
pub main: MainInput,
|
||||
registers: Registers,
|
||||
@ -28,10 +28,7 @@ pub struct ProgramInput {
|
||||
|
||||
impl ProgramInput {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
main: MainInput::new(),
|
||||
registers: Registers::new(),
|
||||
}
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns an empty version of this struct with `None` values.
|
||||
|
@ -20,7 +20,7 @@ use leo_input::{
|
||||
InputParserError,
|
||||
};
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq, Default)]
|
||||
pub struct PrivateState {
|
||||
record: Record,
|
||||
state_leaf: StateLeaf,
|
||||
@ -28,10 +28,7 @@ pub struct PrivateState {
|
||||
|
||||
impl PrivateState {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
record: Record::new(),
|
||||
state_leaf: StateLeaf::new(),
|
||||
}
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns an empty version of this struct with `None` values.
|
||||
|
@ -20,7 +20,7 @@ use leo_input::{
|
||||
InputParserError,
|
||||
};
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq, Default)]
|
||||
pub struct ProgramState {
|
||||
public: PublicState,
|
||||
private: PrivateState,
|
||||
@ -28,10 +28,7 @@ pub struct ProgramState {
|
||||
|
||||
impl ProgramState {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
public: PublicState::new(),
|
||||
private: PrivateState::new(),
|
||||
}
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns an empty version of this struct with `None` values.
|
||||
|
@ -20,14 +20,14 @@ use leo_input::{
|
||||
InputParserError,
|
||||
};
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[derive(Clone, PartialEq, Eq, Default)]
|
||||
pub struct PublicState {
|
||||
state: State,
|
||||
}
|
||||
|
||||
impl PublicState {
|
||||
pub fn new() -> Self {
|
||||
Self { state: State::new() }
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// Returns an empty version of this struct with `None` values.
|
||||
|
Loading…
Reference in New Issue
Block a user