Switch off let-and-return linting
@@ -142,22 +142,20 @@ impl PublicConfigApi {
true
}
+ #[cfg_attr(feature = "cargo-clippy", allow(let_and_return))]
fn get_all_proposes(
&self,
previous_cfg_hash_filter: Option<Hash>,
actual_from_filter: Option<Height>,
) -> Vec<ProposeHashInfo> {
- let snapshot = self.blockchain.snapshot();
- let configuration_schema = ConfigurationSchema::new(&snapshot);
+ let configuration_schema = ConfigurationSchema::new(self.blockchain.snapshot());
let index = configuration_schema.config_hash_by_ordinal();
- let proposes = {
- index
- .into_iter()
+ let proposes_by_hash = configuration_schema.propose_data_by_config_hash();
+
+ let proposes = index
+ .iter()
.map(|cfg_hash| {
- let propose_data = configuration_schema
- .propose_data_by_config_hash()
- .get(&cfg_hash)
- .expect(&format!(
+ let propose_data = proposes_by_hash.get(&cfg_hash).expect(&format!(
"Not found propose for following cfg_hash: {:?}",
cfg_hash
));
@@ -174,32 +172,28 @@ impl PublicConfigApi {
actual_from_filter,
)
})
- .map(|(cfg_hash, propose_data)| {
- ProposeHashInfo {
- hash: cfg_hash,
- propose_data,
- }
+ .map(|(hash, propose_data)| {
+ ProposeHashInfo { hash, propose_data }
})
- .collect::<Vec<_>>()
- };
+ .collect();
proposes
}
+ #[cfg_attr(feature = "cargo-clippy", allow(let_and_return))]
fn get_all_committed(
&self,
previous_cfg_hash_filter: Option<Hash>,
actual_from_filter: Option<Height>,
) -> Vec<ConfigHashInfo> {
- let snapshot = self.blockchain.snapshot();
- let general_schema = Schema::new(&snapshot);
+ let general_schema = Schema::new(self.blockchain.snapshot());
+
let actual_from = general_schema.configs_actual_from();
let configs = general_schema.configs();
- let committed_configs = {
- actual_from
- .into_iter()
- .map(|reference| {
- let config_hash = reference.cfg_hash();
+ let committed_configs = actual_from
+ .iter()
+ .map(|config_ref| {
+ let config_hash = config_ref.cfg_hash();
configs.get(config_hash).expect(&format!(
"Config with hash {:?} is absent in configs table",
config_hash
@@ -213,8 +207,7 @@ impl PublicConfigApi {
)
})
.map(|config| self.get_config_with_proofs(config))
- .collect::<Vec<_>>()
- };
+ .collect();
committed_configs
}
