Skip to content

Commit

Permalink
feat: implemented PartialEq + Eq on all rx collections
Browse files Browse the repository at this point in the history
This makes them work with Sycamore iteration primitives far better.
  • Loading branch information
arctic-hen7 committed Jan 18, 2023
1 parent fb01b9f commit 56ee370
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/perseus/src/state/rx_collections/rx_hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ 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<K, V>(HashMap<K, V>)
where
K: Clone + Eq + Hash,
// We get the `Deserialize` derive macro working by tricking Serde by not
// including the actual bounds here
V: Clone + 'static;
/// The reactive version of [`RxHashMap`].
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RxHashMapRx<K, V>(RcSignal<HashMap<K, RcSignal<V>>>)
where
K: Clone + Serialize + DeserializeOwned + Eq + Hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<K, V>(HashMap<K, V>)
where
K: Clone + Eq + Hash,
Expand All @@ -21,7 +21,7 @@ where
V: MakeRx + 'static,
V::Rx: MakeUnrx<Unrx = V> + Freeze + Clone;
/// The reactive version of [`RxHashMapNested`].
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RxHashMapNestedRx<K, V>(RcSignal<HashMap<K, V::Rx>>)
where
K: Clone + Serialize + DeserializeOwned + Eq + Hash,
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus/src/state/rx_collections/rx_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(Vec<T>)
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<T>(RcSignal<Vec<RcSignal<T>>>)
where
T: Clone + Serialize + DeserializeOwned + 'static;
Expand Down
4 changes: 2 additions & 2 deletions packages/perseus/src/state/rx_collections/rx_vec_nested.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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<T>(Vec<T>)
where
// We get the `Deserialize` derive macro working by tricking Serde by not
// including the actual bounds here
T: MakeRx + 'static,
T::Rx: MakeUnrx<Unrx = T> + Freeze + Clone;
/// The reactive version of [`RxVecNested`].
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct RxVecNestedRx<T>(RcSignal<Vec<T::Rx>>)
where
T: MakeRx + Serialize + DeserializeOwned + 'static,
Expand Down

0 comments on commit 56ee370

Please sign in to comment.