mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-29 08:02:12 +03:00
d3c1966d96
Instead of returning a usize for the window id, I'm instead returning a `WindowHandle<V: View>` where `V` is the type of the window's root view. @as-cii helped me with a cool technique using generic associated types where methods on `WindowHandle` can return either T or Option<T> depending on the `BorrowWindowContext::Result` associated type. Some example usage... ```rs let window = cx.add_window(|cx| MyView::new(cx)); let my_view = window.root(cx); // If cx is TestAppContext, returns MyView. Otherwise returns Option<MyView>, because the window could be closed. ``` This isn't insanely beneficial on its own, but I think it will help clean up our testing story. I'm planning on making `window` more useful in tests for laying out elements, etc. - [x] Rework tests that call `add_window` 😅 to expect only a window in return. - [x] Get tests passing - [x] 🚬 test |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |