Revert "fix(napi): callback should be Fn rather than FnOnce" (#2791)

This reverts commit 7449e5f5cc24e3b92e83aeba68991da7cf8a5b2c.
This commit is contained in:
LongYinan 2025-07-21 20:45:17 +08:00 committed by GitHub
parent 78d76709fa
commit b6f883a053
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 6 deletions

View File

@ -463,17 +463,14 @@ impl<T: FromNapiValue + 'static> futures_core::Stream for Reader<T> {
None => return Poll::Ready(None),
}
}
let waker = cx.waker().clone();
let state = self.state.clone();
let state_in_catch = state.clone();
let waker = cx.waker().clone();
self.inner.call_with_return_value(
Ok(()),
ThreadsafeFunctionCallMode::NonBlocking,
move |iterator, _| {
let iterator = iterator?;
let state = state.clone();
let state_in_catch = state_in_catch.clone();
let waker = waker.clone();
iterator
.then(move |cx| {
if cx.value.done {

View File

@ -481,7 +481,7 @@ impl<
}
/// Call the ThreadsafeFunction, and handle the return value with a callback
pub fn call_with_return_value<F: 'static + Fn(Result<Return>, Env) -> Result<()>>(
pub fn call_with_return_value<F: 'static + FnOnce(Result<Return>, Env) -> Result<()>>(
&self,
value: Result<T, ErrorStatus>,
mode: ThreadsafeFunctionCallMode,
@ -590,7 +590,7 @@ impl<
}
/// Call the ThreadsafeFunction, and handle the return value with a callback
pub fn call_with_return_value<F: 'static + Fn(Result<Return>, Env) -> Result<()>>(
pub fn call_with_return_value<F: 'static + FnOnce(Result<Return>, Env) -> Result<()>>(
&self,
value: T,
mode: ThreadsafeFunctionCallMode,