diff --git a/dunge/src/context.rs b/dunge/src/context.rs index 05faef0..d59bee2 100644 --- a/dunge/src/context.rs +++ b/dunge/src/context.rs @@ -124,11 +124,10 @@ impl Context { CopyBuffer::new(&self.0, size) } - pub async fn map_view<'a, S, R, F>(&self, view: CopyBufferView<'a>, tx: S, rx: R) -> Mapped<'a> + pub async fn map_view<'a, S, R>(&self, view: CopyBufferView<'a>, tx: S, rx: R) -> Mapped<'a> where S: FnOnce(MapResult) + wgpu::WasmNotSend + 'static, - R: FnOnce() -> F, - F: IntoFuture, + R: IntoFuture, { view.map(&self.0, tx, rx).await } diff --git a/dunge/src/texture.rs b/dunge/src/texture.rs index 1eb96f9..42fa8fb 100644 --- a/dunge/src/texture.rs +++ b/dunge/src/texture.rs @@ -305,17 +305,16 @@ pub type MapResult = Result<(), BufferAsyncError>; pub struct CopyBufferView<'a>(BufferSlice<'a>); impl<'a> CopyBufferView<'a> { - pub(crate) async fn map(self, state: &State, tx: S, rx: R) -> Mapped<'a> + pub(crate) async fn map(self, state: &State, tx: S, rx: R) -> Mapped<'a> where S: FnOnce(MapResult) + WasmNotSend + 'static, - R: FnOnce() -> F, - F: IntoFuture, + R: IntoFuture, { use wgpu::*; self.0.map_async(MapMode::Read, tx); state.device().poll(Maintain::Wait); - if let Err(err) = rx().await { + if let Err(err) = rx.await { panic!("failed to copy texture: {err}"); } diff --git a/helpers/src/channel.rs b/helpers/src/channel.rs index 1d58f8f..375fa04 100644 --- a/helpers/src/channel.rs +++ b/helpers/src/channel.rs @@ -1,7 +1,7 @@ use std::{future::Future, pin::Pin}; type Sender = Box; -type Receiver = Box Pin>>>; +type Receiver = Pin>>; pub fn oneshot() -> (Sender, Receiver) where @@ -10,6 +10,6 @@ where let (tx, rx) = async_channel::bounded(1); ( Box::new(move |r| tx.send_blocking(r).expect("send mapped result")), - Box::new(|| Box::pin(async move { rx.recv().await.expect("recv mapped result") })), + Box::pin(async move { rx.recv().await.expect("recv mapped result") }), ) }