Skip to content
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

Unbox async futures #495

Merged
merged 4 commits into from
Oct 1, 2021
Merged

Unbox async futures #495

merged 4 commits into from
Oct 1, 2021

Conversation

maciejhirsz
Copy link
Contributor

There is no need to box futures for async methods in user space, since the closure is captured and boxed internally already.

@@ -32,7 +31,7 @@ pub async fn ws_server() -> String {
let server = WsServerBuilder::default().build("127.0.0.1:0").await.unwrap();
let mut module = RpcModule::new(());
module.register_method(SYNC_METHOD_NAME, |_, _| Ok("lo")).unwrap();
module.register_async_method(ASYNC_METHOD_NAME, |_, _| (async { Ok("lo") }).boxed()).unwrap();
module.register_async_method(ASYNC_METHOD_NAME, |_, _| (async { Ok("lo") })).unwrap();
Copy link
Collaborator

@jsdw jsdw Oct 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need the parens around the async blocks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, don't think they were needed there to begin with!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that too when I saw that they weren't used below in a couple of places :D

Copy link
Collaborator

@jsdw jsdw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

@maciejhirsz maciejhirsz merged commit 615d419 into master Oct 1, 2021
@maciejhirsz maciejhirsz deleted the mh-no-box-async branch October 1, 2021 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants