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

service: improve unsized types' support #650

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tower-service/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Unreleased

- Clarify subtlety around cloning and readiness in the `Service` docs.
- Remove `S: Sized` bound from the `Service` implementation for `&mut S`.
- Improve `poll_ready` examples in the `Service` docs.

# 0.3.1 (November 29, 2019)

Expand Down
13 changes: 7 additions & 6 deletions tower-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,14 @@ use std::task::{Context, Poll};
/// As an example, here is how a Redis request would be issued:
///
/// ```rust,ignore
/// let client = redis::Client::new()
/// let mut client = redis::Client::new()
/// .connect("127.0.0.1:6379".parse().unwrap())
/// .unwrap();
///
/// futures::future::poll_fn(|cx| Service::<Cmd>::poll_ready(&mut client, cx)).await?;
///
/// let resp = client.call(Cmd::set("foo", "this is the value of foo")).await?;
///
/// // Wait for the future to resolve
/// println!("Redis response: {:?}", resp);
/// ```
///
Expand Down Expand Up @@ -260,7 +261,7 @@ use std::task::{Context, Poll};
/// type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
///
/// fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
/// Poll::Ready(Ok(()))
/// self.inner.poll_ready(cx)
/// }
///
/// fn call(&mut self, req: R) -> Self::Future {
Expand Down Expand Up @@ -295,7 +296,7 @@ use std::task::{Context, Poll};
/// type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
///
/// fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
/// Poll::Ready(Ok(()))
/// self.inner.poll_ready(cx)
/// }
///
/// fn call(&mut self, req: R) -> Self::Future {
Expand Down Expand Up @@ -348,9 +349,9 @@ pub trait Service<Request> {
fn call(&mut self, req: Request) -> Self::Future;
}

impl<'a, S, Request> Service<Request> for &'a mut S
impl<S, Request> Service<Request> for &mut S
where
S: Service<Request> + 'a,
S: Service<Request> + ?Sized,
{
type Response = S::Response;
type Error = S::Error;
Expand Down