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

Attach and Launch fairings shouldn't need to be Send + Sync #522

Closed
SergioBenitez opened this issue Dec 28, 2017 · 0 comments
Closed

Attach and Launch fairings shouldn't need to be Send + Sync #522

SergioBenitez opened this issue Dec 28, 2017 · 0 comments
Labels
deficiency Something doesn't work as well as it could

Comments

@SergioBenitez
Copy link
Member

These fairings are called once on the main thread, so the Send + Sync bounds are unnecessary. Furthermore, attach fairings are never stored anywhere, so they don't need the 'static bound. This also implies that AdHoc::on_attach and AdHoc::on_launch should accept an F: FnOnce(..) instead of an Fn.

In all, the loosest bounds are:

  • on_attach: none (FnOnce)
  • on_launch: 'static (FnOnce)
  • on_request: Send + Sync + 'static (Fn)
  • on_response: Send + Sync + 'static (Fn)

It would be ideal if Rocket imposed the least restrictions.

@SergioBenitez SergioBenitez added the deficiency Something doesn't work as well as it could label Dec 28, 2017
SergioBenitez added a commit that referenced this issue Apr 22, 2018
These changes allow any type that implements `FnOnce`, instead of `Fn`,
to be used as attach or launch fairings via `AdHoc`. Furthermore, the
`Sync` bound was also lifted.

Resolves #522.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deficiency Something doesn't work as well as it could
Projects
None yet
Development

No branches or pull requests

1 participant