diff --git a/Cargo.lock b/Cargo.lock index 5158a8beaf49b0..b1ffe471b6e33e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1367,18 +1367,18 @@ dependencies = [ [[package]] name = "enum-iterator" -version = "0.8.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2953d1df47ac0eb70086ccabf0275aa8da8591a28bd358ee2b52bd9f9e3ff9e9" +checksum = "91a4ec26efacf4aeff80887a175a419493cb6f8b5480d26387eb0bd038976187" dependencies = [ "enum-iterator-derive", ] [[package]] name = "enum-iterator-derive" -version = "0.8.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8958699f9359f0b04e691a13850d48b7de329138023876d07cbd024c2c820598" +checksum = "828de45d0ca18782232dfb8f3ea9cc428e8ced380eb26a520baaacfc70de39ce" dependencies = [ "proc-macro2 1.0.41", "quote 1.0.18", diff --git a/program-runtime/Cargo.toml b/program-runtime/Cargo.toml index 27e5c1175188a5..ae2faa4a2de87b 100644 --- a/program-runtime/Cargo.toml +++ b/program-runtime/Cargo.toml @@ -13,6 +13,7 @@ edition = "2021" base64 = "0.13" bincode = "1.3.3" eager = "0.1.0" +enum-iterator = "1.2.0" itertools = "0.10.1" libc = "0.2.101" libloading = "0.7.0" @@ -26,7 +27,6 @@ solana-measure = { path = "../measure", version = "=1.12.0" } solana-metrics = { path = "../metrics", version = "=1.12.0" } solana-sdk = { path = "../sdk", version = "=1.12.0" } thiserror = "1.0" -enum-iterator = "0.8.1" [dev-dependencies] solana-logger = { path = "../logger", version = "=1.12.0" } diff --git a/program-runtime/src/timings.rs b/program-runtime/src/timings.rs index 8e63dfabf5a1d3..c61d8e260fb1b5 100644 --- a/program-runtime/src/timings.rs +++ b/program-runtime/src/timings.rs @@ -1,6 +1,6 @@ use { core::fmt, - enum_iterator::IntoEnumIterator, + enum_iterator::Sequence, solana_sdk::{clock::Slot, pubkey::Pubkey, saturating_add_assign}, std::{ collections::HashMap, @@ -40,7 +40,7 @@ impl ProgramTiming { } /// Used as an index for `Metrics`. -#[derive(Debug, IntoEnumIterator)] +#[derive(Debug, Sequence)] pub enum ExecuteTimingType { CheckUs, LoadUs, @@ -53,7 +53,7 @@ pub enum ExecuteTimingType { UpdateTransactionStatuses, } -pub struct Metrics([u64; ExecuteTimingType::ITEM_COUNT]); +pub struct Metrics([u64; ExecuteTimingType::CARDINALITY]); impl Index for Metrics { type Output = u64; @@ -70,7 +70,7 @@ impl IndexMut for Metrics { impl Default for Metrics { fn default() -> Self { - Metrics([0; ExecuteTimingType::ITEM_COUNT]) + Metrics([0; ExecuteTimingType::CARDINALITY]) } } @@ -337,7 +337,7 @@ impl ExecuteTimings { let idx = timing_type as usize; match self.metrics.0.get_mut(idx) { Some(elem) => *elem = elem.saturating_add(value_to_add), - None => debug_assert!(idx < ExecuteTimingType::ITEM_COUNT, "Index out of bounds"), + None => debug_assert!(idx < ExecuteTimingType::CARDINALITY, "Index out of bounds"), } } } diff --git a/programs/bpf/Cargo.lock b/programs/bpf/Cargo.lock index 648568f12113ca..aae25cffa96a8f 100644 --- a/programs/bpf/Cargo.lock +++ b/programs/bpf/Cargo.lock @@ -1188,18 +1188,18 @@ dependencies = [ [[package]] name = "enum-iterator" -version = "0.8.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2953d1df47ac0eb70086ccabf0275aa8da8591a28bd358ee2b52bd9f9e3ff9e9" +checksum = "91a4ec26efacf4aeff80887a175a419493cb6f8b5480d26387eb0bd038976187" dependencies = [ "enum-iterator-derive", ] [[package]] name = "enum-iterator-derive" -version = "0.8.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8958699f9359f0b04e691a13850d48b7de329138023876d07cbd024c2c820598" +checksum = "828de45d0ca18782232dfb8f3ea9cc428e8ced380eb26a520baaacfc70de39ce" dependencies = [ "proc-macro2 1.0.41", "quote 1.0.18", diff --git a/storage-bigtable/Cargo.toml b/storage-bigtable/Cargo.toml index 0958288e3d4c3c..3eff63440b3bb0 100644 --- a/storage-bigtable/Cargo.toml +++ b/storage-bigtable/Cargo.toml @@ -14,7 +14,7 @@ backoff = { version = "0.4.0", features = ["tokio"] } bincode = "1.3.3" bytes = "1.2" bzip2 = "0.4.3" -enum-iterator = "0.8.1" +enum-iterator = "1.2.0" flate2 = "1.0.24" futures = "0.3.23" goauth = "0.13.1" diff --git a/storage-bigtable/src/compression.rs b/storage-bigtable/src/compression.rs index a2e5bda942d242..90b8ccbe0e4ee9 100644 --- a/storage-bigtable/src/compression.rs +++ b/storage-bigtable/src/compression.rs @@ -1,9 +1,9 @@ use { - enum_iterator::IntoEnumIterator, + enum_iterator::{all, Sequence}, std::io::{self, BufReader, Read, Write}, }; -#[derive(Debug, Serialize, Deserialize, IntoEnumIterator)] +#[derive(Debug, Serialize, Deserialize, Sequence)] pub enum CompressionMethod { NoCompression, Bzip2, @@ -76,7 +76,7 @@ pub fn compress(method: CompressionMethod, data: &[u8]) -> Result, io::E pub fn compress_best(data: &[u8]) -> Result, io::Error> { let mut candidates = vec![]; - for method in CompressionMethod::into_enum_iter() { + for method in all::() { candidates.push(compress(method, data)?); } diff --git a/storage-proto/Cargo.toml b/storage-proto/Cargo.toml index 7c179ff0aea8ad..2c8bfb7e87ad2f 100644 --- a/storage-proto/Cargo.toml +++ b/storage-proto/Cargo.toml @@ -19,7 +19,7 @@ solana-sdk = { path = "../sdk", version = "=1.12.0" } solana-transaction-status = { path = "../transaction-status", version = "=1.12.0" } [dev-dependencies] -enum-iterator = "0.8.1" +enum-iterator = "1.2.0" [lib] crate-type = ["lib"] diff --git a/storage-proto/build.rs b/storage-proto/build.rs index ec975a105411ae..25954b1b8b98b1 100644 --- a/storage-proto/build.rs +++ b/storage-proto/build.rs @@ -19,11 +19,11 @@ fn main() -> Result<(), std::io::Error> { .build_server(false) .type_attribute( "TransactionErrorType", - "#[cfg_attr(test, derive(enum_iterator::IntoEnumIterator))]", + "#[cfg_attr(test, derive(enum_iterator::Sequence))]", ) .type_attribute( "InstructionErrorType", - "#[cfg_attr(test, derive(enum_iterator::IntoEnumIterator))]", + "#[cfg_attr(test, derive(enum_iterator::Sequence))]", ) .compile(&protos, &[proto_base_path]) } diff --git a/storage-proto/src/convert.rs b/storage-proto/src/convert.rs index 399a3eb99f1ac3..d7a9bcdd3819d1 100644 --- a/storage-proto/src/convert.rs +++ b/storage-proto/src/convert.rs @@ -1118,7 +1118,7 @@ impl TryFrom for Vec { #[cfg(test)] mod test { - use {super::*, enum_iterator::IntoEnumIterator}; + use {super::*, enum_iterator::all}; #[test] fn test_reward_type_encode() { @@ -1744,7 +1744,7 @@ mod test { fn test_error_enums() { let ix_index = 1; let custom_error = 42; - for error in tx_by_addr::TransactionErrorType::into_enum_iter() { + for error in all::() { match error { tx_by_addr::TransactionErrorType::DuplicateInstruction | tx_by_addr::TransactionErrorType::InsufficientFundsForRent => { @@ -1762,7 +1762,7 @@ mod test { assert_eq!(tx_by_addr_error, transaction_error.into()); } tx_by_addr::TransactionErrorType::InstructionError => { - for ix_error in tx_by_addr::InstructionErrorType::into_enum_iter() { + for ix_error in all::() { if ix_error != tx_by_addr::InstructionErrorType::Custom { let tx_by_addr_error = tx_by_addr::TransactionError { transaction_error: error as i32,