Why isn't hyper's Service ensuring the poll_ready invariant with typing?
Docs (https://docs.rs/hyper/0.14.18/hyper/service/trait.Service.html#required-methods) say that the user is supposed to wait until poll_ready returns Ready(Ok()) with calling call. Why not instead have poll_ready return Poll<SomeType, Error> and have `call` be a function on SomeType (that takes it by value and consumes it)?
@krzyz Ah, a thing I was missing was that `call` wants mutable access to Service. Thus, if we wanted to make `call` a method on the token, we'd need to have the token borrow the service mutably. However, that we cannot do: the token appears as a result of the future sometime in an uncertain future. So, we need to have call take both a &mut Service and the token, which sort-of requires the ability to have the type system enforce that we use the token with the service it came from.
I see why this doesn't work straightforwardly, but I don't see why GATs solve this issue and what does the issue have to do with behaviour on dropping.
@robryk I think I've found the answer in this issue discussion: https://github.com/tower-rs/tower/issues/412. Looks like tower maintainers have no bandwidth for this change and would like to use GATs for implementation anway.
BTW, I've been seeing quite a few concerns related to stabilizing GATs in their current form recently (see e.g. here: https://github.com/rust-lang/rust/pull/96709#issuecomment-1118275010), so they might be further off than initially expected.