You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to fix for 1.0 but I'm stuck in the following:
src/lib.rs:191:13: 197:14 error: match arms have incompatible types:
expected core::result::Result<(), B>,
found ()
(expected enum core::result::Result,
found ()) [E0308]
src/lib.rs:191 match res {
src/lib.rs:192 Ok(val) => {
src/lib.rs:193 let result = thread::scoped(move || func(val)).join();
src/lib.rs:194 p.resolve(result)
src/lib.rs:195 },
src/lib.rs:196 Err(err) => p.fail(err),
...
src/lib.rs:196:29: 196:40 note: match arm with an incompatible type
src/lib.rs:196 Err(err) => p.fail(err),
^~~~~~~~~~~
src/lib.rs:190:14: 198:11 error: type mismatch: the type [closure src/lib.rs:190:29: 198:10] implements the trait core::ops::FnOnce<(core::result::Result<T, FutureError>,)>, but the trait core::ops::FnOnce<()> is required (expected (), found tuple) [E0281]
src/lib.rs:190 self.on_result(move |res: Result<T,FutureError>| {
src/lib.rs:191 match res {
src/lib.rs:192 Ok(val) => {
src/lib.rs:193 let result = thread::scoped(move || func(val)).join();
src/lib.rs:194 p.resolve(result)
src/lib.rs:195 },
...
pub fn map<B, F>(self, func: F) -> Future<B>
where B: Send, F : FnOnce(T) -> B, T: Send
{
let (p ,f) = promise::<B>();
self.on_result(move |res: Result<T,FutureError>| {
match res {
Ok(val) => {
let result = thread::scoped(move || func(val)).join();
p.resolve(result)
},
Err(err) => p.fail(err),
};
});
f
}
/// Synchronously waits for the result of the Future and returns it.
pub fn get(self) -> Result<T, FutureError> {
match self.receiver.recv() {
Ok(res) => res,
Err(_) => Err(FutureError::HungUp),
}
}
/// Registers a function f that is called with the result of the Future.
/// This function does not block.
pub fn on_result<F: FnOnce() -> Result<T, FutureError> + Send>(self, f: F) {
thread::spawn(move || {
let result = self.get();
f(result);
});
}
why the closure is not getting the type correctly?
The text was updated successfully, but these errors were encountered:
Hi
I'm trying to fix for 1.0 but I'm stuck in the following:
src/lib.rs:191:13: 197:14 error: match arms have incompatible types:
expected
core::result::Result<(), B>
,found
()
(expected enum
core::result::Result
,found ()) [E0308]
src/lib.rs:191 match res {
src/lib.rs:192 Ok(val) => {
src/lib.rs:193 let result = thread::scoped(move || func(val)).join();
src/lib.rs:194 p.resolve(result)
src/lib.rs:195 },
src/lib.rs:196 Err(err) => p.fail(err),
...
src/lib.rs:196:29: 196:40 note: match arm with an incompatible type
src/lib.rs:196 Err(err) => p.fail(err),
^~~~~~~~~~~
src/lib.rs:190:14: 198:11 error: type mismatch: the type
[closure src/lib.rs:190:29: 198:10]
implements the traitcore::ops::FnOnce<(core::result::Result<T, FutureError>,)>
, but the traitcore::ops::FnOnce<()>
is required (expected (), found tuple) [E0281]src/lib.rs:190 self.on_result(move |res: Result<T,FutureError>| {
src/lib.rs:191 match res {
src/lib.rs:192 Ok(val) => {
src/lib.rs:193 let result = thread::scoped(move || func(val)).join();
src/lib.rs:194 p.resolve(result)
src/lib.rs:195 },
...
why the closure is not getting the type correctly?
The text was updated successfully, but these errors were encountered: