Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Allow WeakView<T> to be hashed and compared

Antonio Scandurrae8eea52d0f8c
diff --git a/crates/gpui2/src/view.rs b/crates/gpui2/src/view.rs
index dfc294bc05f..b54afa8dea0 100644
--- a/crates/gpui2/src/view.rs
+++ b/crates/gpui2/src/view.rs
@@ -178,6 +178,20 @@ impl<V> Clone for WeakView<V> {
}
}
+impl<V> Hash for WeakView<V> {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.model.hash(state);
+ }
+}
+
+impl<V> PartialEq for WeakView<V> {
+ fn eq(&self, other: &Self) -> bool {
+ self.model == other.model
+ }
+}
+
+impl<V> Eq for WeakView<V> {}
+
struct EraseViewState<V, ParentV> {
view: View<V>,
parent_view_state_type: PhantomData<ParentV>,