Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Allow View<T> to be hashed and compared
Antonio Scandurra46a99c5c41c2
diff --git a/crates/gpui2/src/view.rs b/crates/gpui2/src/view.rsindex 8bef25b92d7..dfc294bc05f 100644--- a/crates/gpui2/src/view.rs+++ b/crates/gpui2/src/view.rs@@ -4,7 +4,12 @@ use crate::{Size, ViewContext, VisualContext, WeakModel, WindowContext,};use anyhow::{Context, Result};-use std::{any::TypeId, marker::PhantomData, sync::Arc};+use std::{+ any::TypeId,+ hash::{Hash, Hasher},+ marker::PhantomData,+ sync::Arc,+};pub trait Render: 'static + Sized {type Element: Element<Self> + 'static + Send;@@ -76,6 +81,20 @@ impl<V> Clone for View<V> {}}+impl<V> Hash for View<V> {+ fn hash<H: Hasher>(&self, state: &mut H) {+ self.model.hash(state);+ }+}++impl<V> PartialEq for View<V> {+ fn eq(&self, other: &Self) -> bool {+ self.model == other.model+ }+}++impl<V> Eq for View<V> {}+impl<V: Render, ParentViewState: 'static> Component<ParentViewState> for View<V> {fn render(self) -> AnyElement<ParentViewState> {AnyElement::new(EraseViewState {