From 36a09714389fdcf062b4cea1a0f4be172123d61e Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Thu, 21 Nov 2024 11:46:00 +1100 Subject: [PATCH] Switch from derivative to educe (#52) --- Cargo.toml | 2 +- src/leaf.rs | 8 ++++---- src/list.rs | 10 +++++----- src/packed_leaf.rs | 8 ++++---- src/tree.rs | 8 ++++---- src/vector.rs | 10 +++++----- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1e73099..1d898c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ keywords = ["ethereum", "functional"] categories = ["data-structures", "cryptography::cryptocurrencies", ] [dependencies] -derivative = "2.2.0" +educe = "0.6.0" ethereum_hashing = "0.7.0" ethereum_ssz = "0.7.0" ethereum_ssz_derive = "0.7.0" diff --git a/src/leaf.rs b/src/leaf.rs index 285cadd..16b3c75 100644 --- a/src/leaf.rs +++ b/src/leaf.rs @@ -3,14 +3,14 @@ use crate::{ Arc, }; use arbitrary::Arbitrary; -use derivative::Derivative; +use educe::Educe; use parking_lot::RwLock; use tree_hash::Hash256; -#[derive(Debug, Derivative, Arbitrary)] -#[derivative(PartialEq, Hash)] +#[derive(Debug, Educe, Arbitrary)] +#[educe(PartialEq, Hash)] pub struct Leaf { - #[derivative(PartialEq = "ignore", Hash = "ignore")] + #[educe(PartialEq(ignore), Hash(ignore))] #[arbitrary(with = arb_rwlock)] pub hash: RwLock, #[arbitrary(with = arb_arc)] diff --git a/src/list.rs b/src/list.rs index f3d8676..262e1ea 100644 --- a/src/list.rs +++ b/src/list.rs @@ -9,7 +9,7 @@ use crate::update_map::MaxMap; use crate::utils::{arb_arc, compute_level, int_log, opt_packing_depth, updated_length, Length}; use crate::{Arc, Cow, Error, Tree, UpdateMap, Value}; use arbitrary::Arbitrary; -use derivative::Derivative; +use educe::Educe; use itertools::process_results; use serde::{ser::SerializeSeq, Deserialize, Deserializer, Serialize, Serializer}; use ssz::{Decode, Encode, SszEncoder, TryFromIter, BYTES_PER_LENGTH_OFFSET}; @@ -19,16 +19,16 @@ use tree_hash::{Hash256, PackedEncoding, TreeHash}; use typenum::Unsigned; use vec_map::VecMap; -#[derive(Debug, Clone, Derivative, Arbitrary)] -#[derivative(PartialEq(bound = "T: Value, N: Unsigned, U: UpdateMap + PartialEq"))] +#[derive(Debug, Clone, Educe, Arbitrary)] +#[educe(PartialEq(bound(T: Value, N: Unsigned, U: UpdateMap + PartialEq)))] #[arbitrary(bound = "T: Arbitrary<'arbitrary> + Value")] #[arbitrary(bound = "N: Unsigned, U: Arbitrary<'arbitrary> + UpdateMap + PartialEq")] pub struct List = MaxMap>> { pub(crate) interface: Interface, U>, } -#[derive(Debug, Clone, Derivative, Arbitrary)] -#[derivative(PartialEq(bound = "T: Value, N: Unsigned"))] +#[derive(Debug, Clone, Educe, Arbitrary)] +#[educe(PartialEq(bound(T: Value, N: Unsigned)))] #[arbitrary(bound = "T: Arbitrary<'arbitrary> + Value, N: Unsigned")] pub struct ListInner { #[arbitrary(with = arb_arc)] diff --git a/src/packed_leaf.rs b/src/packed_leaf.rs index e867bff..512f3ef 100644 --- a/src/packed_leaf.rs +++ b/src/packed_leaf.rs @@ -1,14 +1,14 @@ use crate::{utils::arb_rwlock, Error, UpdateMap}; use arbitrary::Arbitrary; -use derivative::Derivative; +use educe::Educe; use parking_lot::RwLock; use std::ops::ControlFlow; use tree_hash::{Hash256, TreeHash, BYTES_PER_CHUNK}; -#[derive(Debug, Derivative, Arbitrary)] -#[derivative(PartialEq, Hash)] +#[derive(Debug, Educe, Arbitrary)] +#[educe(PartialEq, Hash)] pub struct PackedLeaf { - #[derivative(PartialEq = "ignore", Hash = "ignore")] + #[educe(PartialEq(ignore), Hash(ignore))] #[arbitrary(with = arb_rwlock)] pub hash: RwLock, pub(crate) values: Vec, diff --git a/src/tree.rs b/src/tree.rs index ac306d2..e8668a5 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -1,20 +1,20 @@ use crate::utils::{arb_arc, arb_rwlock, opt_hash, opt_packing_depth, opt_packing_factor, Length}; use crate::{Arc, Error, Leaf, PackedLeaf, UpdateMap, Value}; use arbitrary::Arbitrary; -use derivative::Derivative; +use educe::Educe; use ethereum_hashing::{hash32_concat, ZERO_HASHES}; use parking_lot::RwLock; use std::collections::BTreeMap; use std::ops::ControlFlow; use tree_hash::Hash256; -#[derive(Debug, Derivative, Arbitrary)] -#[derivative(PartialEq, Hash)] +#[derive(Debug, Educe, Arbitrary)] +#[educe(PartialEq(bound(T: Value)), Hash)] pub enum Tree { Leaf(Leaf), PackedLeaf(PackedLeaf), Node { - #[derivative(PartialEq = "ignore", Hash = "ignore")] + #[educe(PartialEq(ignore), Hash(ignore))] #[arbitrary(with = arb_rwlock)] hash: RwLock, #[arbitrary(with = arb_arc)] diff --git a/src/vector.rs b/src/vector.rs index f5b6711..08544d1 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -7,7 +7,7 @@ use crate::update_map::MaxMap; use crate::utils::{arb_arc, Length}; use crate::{Arc, Cow, Error, List, Tree, UpdateMap, Value}; use arbitrary::Arbitrary; -use derivative::Derivative; +use educe::Educe; use serde::{Deserialize, Serialize}; use ssz::{Decode, Encode, SszEncoder, TryFromIter, BYTES_PER_LENGTH_OFFSET}; use std::collections::BTreeMap; @@ -17,8 +17,8 @@ use tree_hash::{Hash256, PackedEncoding}; use typenum::Unsigned; use vec_map::VecMap; -#[derive(Debug, Derivative, Clone, Serialize, Deserialize, Arbitrary)] -#[derivative(PartialEq(bound = "T: Value, N: Unsigned, U: UpdateMap + PartialEq"))] +#[derive(Debug, Educe, Clone, Serialize, Deserialize, Arbitrary)] +#[educe(PartialEq(bound(T: Value, N: Unsigned, U: UpdateMap + PartialEq)))] #[serde(try_from = "List")] #[serde(into = "List")] #[serde(bound(serialize = "T: Value + Serialize, N: Unsigned, U: UpdateMap"))] @@ -29,8 +29,8 @@ pub struct Vector = MaxMap>> { pub(crate) interface: Interface, U>, } -#[derive(Debug, Derivative, Clone, Arbitrary)] -#[derivative(PartialEq(bound = "T: Value, N: Unsigned"))] +#[derive(Debug, Educe, Clone, Arbitrary)] +#[educe(PartialEq(bound(T: Value, N: Unsigned)))] #[arbitrary(bound = "T: Arbitrary<'arbitrary> + Value, N: Unsigned")] pub struct VectorInner { #[arbitrary(with = arb_arc)]