From 56ee370aafeccd35227019cbe6b377dbdf76f274 Mon Sep 17 00:00:00 2001 From: arctic-hen7 Date: Thu, 19 Jan 2023 06:44:36 +1030 Subject: [PATCH] feat: implemented `PartialEq + Eq` on all rx collections This makes them work with Sycamore iteration primitives far better. --- packages/perseus/src/state/rx_collections/rx_hash_map.rs | 4 ++-- .../perseus/src/state/rx_collections/rx_hash_map_nested.rs | 4 ++-- packages/perseus/src/state/rx_collections/rx_vec.rs | 4 ++-- packages/perseus/src/state/rx_collections/rx_vec_nested.rs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/perseus/src/state/rx_collections/rx_hash_map.rs b/packages/perseus/src/state/rx_collections/rx_hash_map.rs index d648058fe2..35453fe0f2 100644 --- a/packages/perseus/src/state/rx_collections/rx_hash_map.rs +++ b/packages/perseus/src/state/rx_collections/rx_hash_map.rs @@ -12,7 +12,7 @@ use sycamore::reactive::{create_rc_signal, RcSignal}; /// and it wraps them in `RcSignal`s to make them reactive. If you want to store /// nested reactive types inside the map (e.g. `String`s), you should /// use [`super::RxHashMapNested`]. -#[derive(Serialize, Deserialize, Clone, Debug)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct RxHashMap(HashMap) where K: Clone + Eq + Hash, @@ -20,7 +20,7 @@ where // including the actual bounds here V: Clone + 'static; /// The reactive version of [`RxHashMap`]. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct RxHashMapRx(RcSignal>>) where K: Clone + Serialize + DeserializeOwned + Eq + Hash, diff --git a/packages/perseus/src/state/rx_collections/rx_hash_map_nested.rs b/packages/perseus/src/state/rx_collections/rx_hash_map_nested.rs index 81c52e949d..7836f45a31 100644 --- a/packages/perseus/src/state/rx_collections/rx_hash_map_nested.rs +++ b/packages/perseus/src/state/rx_collections/rx_hash_map_nested.rs @@ -12,7 +12,7 @@ use sycamore::reactive::{create_rc_signal, RcSignal}; /// (usually derived with the `ReactiveState` macro). If you want to store /// simple types inside the vector, without nested reactivity (e.g. `String`s), /// you should use [`super::RxHashMap`]. -#[derive(Serialize, Deserialize, Clone, Debug)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct RxHashMapNested(HashMap) where K: Clone + Eq + Hash, @@ -21,7 +21,7 @@ where V: MakeRx + 'static, V::Rx: MakeUnrx + Freeze + Clone; /// The reactive version of [`RxHashMapNested`]. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct RxHashMapNestedRx(RcSignal>) where K: Clone + Serialize + DeserializeOwned + Eq + Hash, diff --git a/packages/perseus/src/state/rx_collections/rx_vec.rs b/packages/perseus/src/state/rx_collections/rx_vec.rs index 66ccb02cd3..ed756ec72a 100644 --- a/packages/perseus/src/state/rx_collections/rx_vec.rs +++ b/packages/perseus/src/state/rx_collections/rx_vec.rs @@ -10,14 +10,14 @@ use sycamore::reactive::{create_rc_signal, RcSignal}; /// vector, and it wraps them in `RcSignal`s to make them reactive. If you want /// to store nested reactive types inside the vector (e.g. `String`s), you /// should use [`super::RxVecNested`]. -#[derive(Serialize, Deserialize, Clone, Debug)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct RxVec(Vec) where // We get the `Deserialize` derive macro working by tricking Serde by not // including the actual bounds here T: Clone + 'static; /// The reactive version of [`RxVec`]. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct RxVecRx(RcSignal>>) where T: Clone + Serialize + DeserializeOwned + 'static; diff --git a/packages/perseus/src/state/rx_collections/rx_vec_nested.rs b/packages/perseus/src/state/rx_collections/rx_vec_nested.rs index 3915456bf4..8d761cfbb0 100644 --- a/packages/perseus/src/state/rx_collections/rx_vec_nested.rs +++ b/packages/perseus/src/state/rx_collections/rx_vec_nested.rs @@ -10,7 +10,7 @@ use sycamore::reactive::{create_rc_signal, RcSignal}; /// derived with the `ReactiveState` macro). If you want to store simple types /// inside the vector, without nested reactivity (e.g. `String`s), you should /// use [`super::RxVec`]. -#[derive(Serialize, Deserialize, Clone, Debug)] +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct RxVecNested(Vec) where // We get the `Deserialize` derive macro working by tricking Serde by not @@ -18,7 +18,7 @@ where T: MakeRx + 'static, T::Rx: MakeUnrx + Freeze + Clone; /// The reactive version of [`RxVecNested`]. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct RxVecNestedRx(RcSignal>) where T: MakeRx + Serialize + DeserializeOwned + 'static,