-
Notifications
You must be signed in to change notification settings - Fork 51
Coding Style
Seulgi Kim edited this page Apr 2, 2019
·
11 revisions
Group imports into 3 groups:
- System
- Other Package
- Self Package
use std::collections::HashSet;
use codechain_types::{Address, H256};
use crypto::BLAKE_NULL_RLP;
use rlp::{UntrustedRlp, RlpStream, Encodable, Decodable, DecoderError};
use triehash::ordered_trie_root;
use super::Bytes;
use super::codechain_machine::CodeChainMachine;
use super::engine::ConsensusEngine;
use super::error::Error;
use super::header::{Header, Seal};
use super::machine::{LiveBlock, Transactions};
use super::transaction::{UnverifiedTransaction, SignedTransaction, TransactionError};
Reduce codechain_
prefix in package name to c
.
extern crate codechain_crypto as ccrypto;
extern crate codechain_io as cio;
extern crate codechain_types as ctypes;
For example, kademlia
module exports Config
and Extension
as KademliaConfig
and KademliaExtension
respectively to avoid confusion.
pub use self::config::Config as KademliaConfig;
pub use self::extension::Extension as KademliaExtension;
Make sure you run rustfmt
before pushing changes to the repo. You need to install the nightly-2018-07-17 version of rustfmt
.
rustup toolchain install nightly-2018-12-06
rustup component add rustfmt-preview --toolchain nightly-2018-12-06
To run rustfmt
,
cargo +nightly-2018-12-06 fmt
It's recommended to put the below script file to .git/hooks/post-commit
or another hook(such as pre-push). It will let you know the breaking points without modifying any files.
#!/bin/sh
cargo +nightly-2018-12-06 fmt -- --check