Checkpoint
This commit is contained in:
parent
90601fe4fd
commit
9798d65cf9
8 changed files with 51 additions and 51 deletions
|
@ -95,11 +95,11 @@ pub trait Context {
|
|||
}
|
||||
|
||||
pub trait VisualContext: Context {
|
||||
type ViewContext<'a, 'w, V: 'static>;
|
||||
type ViewContext<'a, V: 'static>;
|
||||
|
||||
fn build_view<V>(
|
||||
&mut self,
|
||||
build_view_state: impl FnOnce(&mut Self::ViewContext<'_, '_, V>) -> V,
|
||||
build_view_state: impl FnOnce(&mut Self::ViewContext<'_, V>) -> V,
|
||||
) -> Self::Result<View<V>>
|
||||
where
|
||||
V: 'static + Send;
|
||||
|
@ -107,7 +107,7 @@ pub trait VisualContext: Context {
|
|||
fn update_view<V: 'static, R>(
|
||||
&mut self,
|
||||
view: &View<V>,
|
||||
update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, '_, V>) -> R,
|
||||
update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, V>) -> R,
|
||||
) -> Self::Result<R>;
|
||||
}
|
||||
|
||||
|
@ -184,11 +184,11 @@ impl<C: Context> Context for MainThread<C> {
|
|||
}
|
||||
|
||||
impl<C: VisualContext> VisualContext for MainThread<C> {
|
||||
type ViewContext<'a, 'w, V: 'static> = MainThread<C::ViewContext<'a, 'w, V>>;
|
||||
type ViewContext<'a, V: 'static> = MainThread<C::ViewContext<'a, V>>;
|
||||
|
||||
fn build_view<V>(
|
||||
&mut self,
|
||||
build_view_state: impl FnOnce(&mut Self::ViewContext<'_, '_, V>) -> V,
|
||||
build_view_state: impl FnOnce(&mut Self::ViewContext<'_, V>) -> V,
|
||||
) -> Self::Result<View<V>>
|
||||
where
|
||||
V: 'static + Send,
|
||||
|
@ -196,8 +196,8 @@ impl<C: VisualContext> VisualContext for MainThread<C> {
|
|||
self.0.build_view(|cx| {
|
||||
let cx = unsafe {
|
||||
mem::transmute::<
|
||||
&mut C::ViewContext<'_, '_, V>,
|
||||
&mut MainThread<C::ViewContext<'_, '_, V>>,
|
||||
&mut C::ViewContext<'_, V>,
|
||||
&mut MainThread<C::ViewContext<'_, V>>,
|
||||
>(cx)
|
||||
};
|
||||
build_view_state(cx)
|
||||
|
@ -207,13 +207,13 @@ impl<C: VisualContext> VisualContext for MainThread<C> {
|
|||
fn update_view<V: 'static, R>(
|
||||
&mut self,
|
||||
view: &View<V>,
|
||||
update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, '_, V>) -> R,
|
||||
update: impl FnOnce(&mut V, &mut Self::ViewContext<'_, V>) -> R,
|
||||
) -> Self::Result<R> {
|
||||
self.0.update_view(view, |view_state, cx| {
|
||||
let cx = unsafe {
|
||||
mem::transmute::<
|
||||
&mut C::ViewContext<'_, '_, V>,
|
||||
&mut MainThread<C::ViewContext<'_, '_, V>>,
|
||||
&mut C::ViewContext<'_, V>,
|
||||
&mut MainThread<C::ViewContext<'_, V>>,
|
||||
>(cx)
|
||||
};
|
||||
update(view_state, cx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue