Skip to content

Commit 248c21e

Browse files
committed
Fix a compile error
Not sure how I didn't catch this earlier. The `output` is borrowed by the future and can't be returned. This can be fixed by using a `Cell` to share the value with the future and then replacing the inner value. Signed-off-by: John Nunley <dev@notgull.net>
1 parent 5d5edcd commit 248c21e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/filter.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Public License along with `async-winit`. If not, see <https://www.gnu.org/licens
2222
//! `winit` applications. The `Filter` type can be provided events, and will send those events to this
2323
//! library's event handlers.
2424
25+
use std::cell::Cell;
2526
use std::cmp;
2627
use std::future::Future;
2728
use std::pin::Pin;
@@ -133,11 +134,11 @@ impl<TS: ThreadSafety> Filter<TS> {
133134
F: Future,
134135
{
135136
// Create a future that can be polled freely.
136-
let mut output = ReturnOrFinish::Output(());
137+
let output = Cell::new(ReturnOrFinish::Output(()));
137138
let future = {
138-
let output = &mut output;
139+
let output = &output;
139140
async move {
140-
*output = ReturnOrFinish::FutureReturned(future.await);
141+
output.set(ReturnOrFinish::FutureReturned(future.await));
141142
}
142143
};
143144
futures_lite::pin!(future);
@@ -264,7 +265,7 @@ impl<TS: ThreadSafety> Filter<TS> {
264265
}
265266

266267
// Return the output if any.
267-
output
268+
output.replace(ReturnOrFinish::Output(()))
268269
}
269270
}
270271

0 commit comments

Comments
 (0)