async-stream
async-stream copied to clipboard
Box::pin vs pin_mut!(s);
trafficstars
Requiring pin_mut!(s); at the usage site may be efficient, but it is an awkward requirement for users of such API.
I've found that wrapping returned stream in Box::pin makes it "just work". I suspect that for network-bound streams the overhead will be negligible.
Could you mention this alternative in the docs?
@kornelski I think the prefered usage is using pin_mut or tokio::pin but I think we could shoutout box::pin in the docs, would you possibly be able to PR this? :)