Use collect() to avoid a lint
This commit is contained in:
parent
eadbea1423
commit
49e6150427
|
|
@ -404,9 +404,7 @@ where
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use std::{
|
use std::{collections::hash_map::RandomState, collections::HashSet, fmt::Debug};
|
||||||
collections::hash_map::RandomState, collections::HashSet, fmt::Debug, iter::FromIterator,
|
|
||||||
};
|
|
||||||
|
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
|
|
||||||
|
|
@ -601,20 +599,19 @@ mod test {
|
||||||
let another_one = Amount::<NonNegative>::try_from(1)?;
|
let another_one = Amount::<NonNegative>::try_from(1)?;
|
||||||
let zero = Amount::<NonNegative>::try_from(0)?;
|
let zero = Amount::<NonNegative>::try_from(0)?;
|
||||||
|
|
||||||
let hash_set: HashSet<Amount<NonNegative>, RandomState> =
|
let hash_set: HashSet<Amount<NonNegative>, RandomState> = [one].iter().cloned().collect();
|
||||||
HashSet::from_iter([one].iter().cloned());
|
|
||||||
assert_eq!(hash_set.len(), 1);
|
assert_eq!(hash_set.len(), 1);
|
||||||
|
|
||||||
let hash_set: HashSet<Amount<NonNegative>, RandomState> =
|
let hash_set: HashSet<Amount<NonNegative>, RandomState> =
|
||||||
HashSet::from_iter([one, one].iter().cloned());
|
[one, one].iter().cloned().collect();
|
||||||
assert_eq!(hash_set.len(), 1, "Amount hashes are consistent");
|
assert_eq!(hash_set.len(), 1, "Amount hashes are consistent");
|
||||||
|
|
||||||
let hash_set: HashSet<Amount<NonNegative>, RandomState> =
|
let hash_set: HashSet<Amount<NonNegative>, RandomState> =
|
||||||
HashSet::from_iter([one, another_one].iter().cloned());
|
[one, another_one].iter().cloned().collect();
|
||||||
assert_eq!(hash_set.len(), 1, "Amount hashes are by value");
|
assert_eq!(hash_set.len(), 1, "Amount hashes are by value");
|
||||||
|
|
||||||
let hash_set: HashSet<Amount<NonNegative>, RandomState> =
|
let hash_set: HashSet<Amount<NonNegative>, RandomState> =
|
||||||
HashSet::from_iter([one, zero].iter().cloned());
|
[one, zero].iter().cloned().collect();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
hash_set.len(),
|
hash_set.len(),
|
||||||
2,
|
2,
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,6 @@
|
||||||
|
|
||||||
// Each lazy_static variable uses additional recursion
|
// Each lazy_static variable uses additional recursion
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
// Disable some broken or unwanted clippy nightly lints
|
|
||||||
// Build without warnings on nightly 2021-01-17 and later and stable 1.51 and later
|
|
||||||
#![allow(unknown_lints)]
|
|
||||||
// Disable old lint warnings on nightly until 1.51 is stable
|
|
||||||
#![allow(renamed_and_removed_lints)]
|
|
||||||
// Use the old lint name to build without warnings on stable until 1.51 is stable
|
|
||||||
#![allow(clippy::unknown_clippy_lints)]
|
|
||||||
// The actual lints we want to disable
|
|
||||||
#![allow(clippy::from_iter_instead_of_collect)]
|
|
||||||
|
|
||||||
use color_eyre::section::PanicMessage;
|
use color_eyre::section::PanicMessage;
|
||||||
use owo_colors::OwoColorize;
|
use owo_colors::OwoColorize;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use hex::FromHex;
|
use hex::FromHex;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
use std::{collections::BTreeMap, iter::FromIterator};
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|
||||||
|
|
@ -22,8 +22,7 @@ lazy_static! {
|
||||||
/// Mainnet blocks, indexed by height
|
/// Mainnet blocks, indexed by height
|
||||||
///
|
///
|
||||||
/// This is actually a bijective map, the tests ensure that values are unique.
|
/// This is actually a bijective map, the tests ensure that values are unique.
|
||||||
pub static ref MAINNET_BLOCKS: BTreeMap<u32, &'static [u8]> = BTreeMap::from_iter(
|
pub static ref MAINNET_BLOCKS: BTreeMap<u32, &'static [u8]> = [
|
||||||
[
|
|
||||||
// Genesis
|
// Genesis
|
||||||
(0, BLOCK_MAINNET_GENESIS_BYTES.as_ref()),
|
(0, BLOCK_MAINNET_GENESIS_BYTES.as_ref()),
|
||||||
// BeforeOverwinter
|
// BeforeOverwinter
|
||||||
|
|
@ -62,14 +61,12 @@ lazy_static! {
|
||||||
(975_066, BLOCK_MAINNET_975066_BYTES.as_ref()),
|
(975_066, BLOCK_MAINNET_975066_BYTES.as_ref()),
|
||||||
(982_681, BLOCK_MAINNET_982681_BYTES.as_ref()),
|
(982_681, BLOCK_MAINNET_982681_BYTES.as_ref()),
|
||||||
// TODO: Canopy and First Halving, see #1099
|
// TODO: Canopy and First Halving, see #1099
|
||||||
].iter().cloned()
|
].iter().cloned().collect();
|
||||||
);
|
|
||||||
|
|
||||||
/// Testnet blocks, indexed by height
|
/// Testnet blocks, indexed by height
|
||||||
///
|
///
|
||||||
/// This is actually a bijective map, the tests ensure that values are unique.
|
/// This is actually a bijective map, the tests ensure that values are unique.
|
||||||
pub static ref TESTNET_BLOCKS: BTreeMap<u32, &'static [u8]> = BTreeMap::from_iter(
|
pub static ref TESTNET_BLOCKS: BTreeMap<u32, &'static [u8]> = [
|
||||||
[
|
|
||||||
// Genesis
|
// Genesis
|
||||||
(0, BLOCK_TESTNET_GENESIS_BYTES.as_ref()),
|
(0, BLOCK_TESTNET_GENESIS_BYTES.as_ref()),
|
||||||
// BeforeOverwinter
|
// BeforeOverwinter
|
||||||
|
|
@ -120,8 +117,7 @@ lazy_static! {
|
||||||
// Shielded coinbase
|
// Shielded coinbase
|
||||||
(1_101_629, BLOCK_TESTNET_1101629_BYTES.as_ref()),
|
(1_101_629, BLOCK_TESTNET_1101629_BYTES.as_ref()),
|
||||||
// TODO: First Halving, see #1104
|
// TODO: First Halving, see #1104
|
||||||
].iter().cloned()
|
].iter().cloned().collect();
|
||||||
);
|
|
||||||
|
|
||||||
// Mainnet
|
// Mainnet
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue