tower icon indicating copy to clipboard operation
tower copied to clipboard

service: improve unsized types' support

Open cppforliving opened this issue 3 years ago • 4 comments

While Service impl for Box<S> covers unsized S case, the impl for &mut S is not, this PR is an attempt to fix that.

Also there are a few places in Service docs where the poll_ready call seems to be missing.

cppforliving avatar Mar 09 '22 22:03 cppforliving

I'm curious what your use case for this is 🤔

I've personally considered removing this blanket impl and instead have a blanket impl for async functions so we wouldn't need service_fn.

davidpdrsn avatar Mar 10 '22 07:03 davidpdrsn

Not that I particularly need this, I just spotted https://github.com/tower-rs/tower/issues/636 so I looked at tower-service API and noticed this minor asymmetry.

I really like the idea of adding blanket impl for async functions, however it seems that removing existing blanket impls would require reworking tower::util::Ready as its current impl relies on the &mut Service blanket impl. Maybe a bit unrelated example, but std::future::Future has a blanket impls for &mut Future and Box<Future> which to me seems quite useful, so maybe it would be worthy to keep similar blanket impls for tower::Service as well, just thinking...

cppforliving avatar Mar 13 '22 20:03 cppforliving

Any thoughts on this?

cppforliving avatar Mar 20 '22 10:03 cppforliving

I filed a proposal for removing the old blanket impls https://github.com/tower-rs/tower/pull/657

davidpdrsn avatar Mar 21 '22 10:03 davidpdrsn