futures-rs: `SinkExt::send` and `send_all`, and `StreamExt::next` should not need `Self: Unpin`
There is, as far as I understand, no theoretical reason for send or send_all to require Self: Unpin.
The only reason being that the current implementation requires it, changing the implementation to not require Self: Unpin would be great.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (9 by maintainers)
I kind of agree that the existing method should still exist, what I argue is for it to exist under another name, so that the most obvious name is also the 0-cost one, to try and follow Rust’s philosophy. Hence my suggestion of making
send& co. takePin<&mut Self>without requiringSelf: Unpinand to add asend_unpinthat does requireSelf: Unpinlike:As for the stream generated by
#[async_stream], if it is like futures then it will be!Unpinas soon as a borrow will live across anawaitpoint, which will quite likely be pretty often (after all that’s exactly the reason whyPinwas introduced in the first place, though other use cases also called for it)It still adds code-readability overhead
vs
or
The majority of concrete
Sinks are likely to beUnpin, and when working with generic sinks you will commonly want to request anUnpinsink and push the pinning requirement up to your callers (it will probably be worth having some guidelines around when you want to have+ Unpinand when you should stack-pin yourself once there’s more familiarity with which is better).