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

refactor(service): change Service::call to take &self #3223

Merged
merged 1 commit into from
May 15, 2023

Commits on May 12, 2023

  1. refactor(service): change Service::call to take &self

    change Service::call to take &self instead of &mut self.
    Because of this change, the trait bound in the service::util::service_fn and
    the trait bound in the impl for the ServiceFn struct were changed from FnMut to Fn.
    This change was decided on for the following reasons:
    - It prepares the way for async fn,
      since then the future only borrows &self, and thus a Service can concurrently handle
      multiple outstanding requests at once.
    - It's clearer that Services can likely be cloned
    - To share state across clones you generally need Arc<Mutex<_>>
      that means you're not really using the &mut self and could do with a &self
    
    This commit closses issue: hyperium#3040
    BREAKING CHANGE: The Service::call function no longer takes a mutable reference to self.
    The FnMut trait bound on the service::util::service_fn function and the trait bound
    on the impl for the ServiceFn struct were changed from FnMut to Fn
    Robin Seitz committed May 12, 2023
    Configuration menu
    Copy the full SHA
    4d90bc1 View commit details
    Browse the repository at this point in the history