-
Notifications
You must be signed in to change notification settings - Fork 654
[Question] why boxed() failed to compile. #363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I can get it to typecheck by switching from core.run(
line::Client::connect(&addr, &handle)
.map(Box::new)
.and_then(|client| {
let init = Box::new(::futures::future::ok(client))
as Box<Future<Item=Box<line::Client>,Error=::std::io::Error>>;
(0..10).into_iter().fold(init, move |f, i| {
Box::new(f.and_then(move |client| {
client.call(format!("iter {}", i))
.map(move |response| {
println!("-> {:?}", response);
client
})
}))
})
})
).unwrap(); Note that the future you are constructing here will have size proportional to your iterator, which in this case has ten elements. A better approach might be to use |
I believe @dwrensha was spot on, so closing. Thanks for the report though! |
@dwrensha thank you very much. It is a very clear explaination. |
The whole |
I write a test code which is a modified version of https://github.com/tokio-rs/tokio-line/blob/master/multiplexed/examples/echo_client_server.rs
Just few lines (see below) are replaced:
What I want is send requests one by one after previous response back.
But this can not compiled,
It am very puzzled by this, and have no idea how to fix it. Could anyone here give my some help?
The text was updated successfully, but these errors were encountered: