Skip to content

Commit

Permalink
docs(service): minor language fixes to Service::call (hyperium#3449)
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Pfennig <s.pfennig@reply.de>
  • Loading branch information
Allan authored and 0xE282B0 committed Jan 16, 2024
1 parent 77f72de commit d7c1535
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ pub trait Service<Request> {
type Future: Future<Output = Result<Self::Response, Self::Error>>;

/// Process the request and return the response asynchronously.
/// call takes a &self instead of a mut &self because:
/// `call` takes `&self` instead of `mut &self` because:
/// - It prepares the way for async fn,
/// since then the future only borrows &self, and thus a Service can concurrently handle
/// 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
/// To see the discussion on this see: <https://github.com/hyperium/hyper/issues/3040>
/// - 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`.
/// The discussion on this is here: <https://github.com/hyperium/hyper/issues/3040>
fn call(&self, req: Request) -> Self::Future;
}

0 comments on commit d7c1535

Please sign in to comment.