-
Notifications
You must be signed in to change notification settings - Fork 172
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
Unbox async futures #495
Conversation
benches/helpers.rs
Outdated
@@ -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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
There is no need to box futures for async methods in user space, since the closure is captured and boxed internally already.