Skip to content

Organize imports with rustfmt #162

@ed255

Description

@ed255

In my last PRs I felt that the imports organization were getting out of hand.
Not only with unused imports, but in particular I haven't put the effort to have clean imports and this means lots of unstructured lines importing stuff like:

use anyhow::Result;
use itertools::Itertools;
use plonky2::{
field::types::Field,
hash::{
hash_types::{HashOut, HashOutTarget},
poseidon::PoseidonHash,
},
iop::{
target::{BoolTarget, Target},
witness::{PartialWitness, WitnessWrite},
},
plonk::circuit_builder::CircuitBuilder,
};
use std::collections::HashMap;
use std::iter;
use crate::backends::plonky2::basetypes::{Hash, Value, D, EMPTY_HASH, EMPTY_VALUE, F, VALUE_SIZE};
use crate::backends::plonky2::circuits::common::{
CircuitBuilderPod, OperationTarget, StatementTarget, ValueTarget,
};
use crate::backends::plonky2::primitives::merkletree::{MerkleProof, MerkleTree};
use crate::backends::plonky2::primitives::merkletree::{
MerkleProofExistenceGate, MerkleProofExistenceTarget,
};
use crate::middleware::{
hash_str, AnchoredKey, NativeOperation, NativePredicate, Params, PodType, Predicate, Statement,
StatementArg, ToFields, KEY_TYPE, SELF, STATEMENT_ARG_F_LEN,
};

For example here I was sloppy and I didn't merge line 22 and 23.

This chore can be easily automated with a configuration of rustfmt, so I would propose to add a rustfmt.toml file in the root with these settings:

imports_granularity = "Crate"

See https://rust-lang.github.io/rustfmt/?version=v1.8.0&search=imports_gran#imports_granularity

Metadata

Metadata

Assignees

Labels

refactorRefactoring task that may be left for the appropriate time

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions