Zed2 entities (#3189)

Adds an `Entity` trait for abstracting over `View`s and `Model`s, and
implements it for the `subscribe()` and `observe()` APIs.

The last commit also includes a fun experiment I added, using the
`Result` type to return the owned model handles back to the caller in
the case of downcast failure, inspired by the `binary_search*` methods.
This commit is contained in:
Antonio Scandurra 2023-10-31 10:11:25 +01:00 committed by GitHub
commit 88875fd006
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 214 additions and 107 deletions

View file

@ -730,7 +730,7 @@ impl Context for AppContext {
/// Update the entity referenced by the given model. The function is passed a mutable reference to the
/// entity along with a `ModelContext` for the entity.
fn update_entity<T: 'static, R>(
fn update_model<T: 'static, R>(
&mut self,
model: &Model<T>,
update: impl FnOnce(&mut T, &mut Self::ModelContext<'_, T>) -> R,