async-stream icon indicating copy to clipboard operation
async-stream copied to clipboard

Box::pin vs pin_mut!(s);

Open kornelski opened this issue 5 years ago • 1 comments
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 avatar Feb 10 '20 13:02 kornelski

@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? :)

LucioFranco avatar Feb 11 '20 01:02 LucioFranco