What's the idiomatic way to append a slice to a vector?

前端 未结 3 913
执念已碎
执念已碎 2021-01-07 16:41

I have a slice of &[u8] and I\'d like to append it to a Vec with minimal copying. Here are two approaches that I know work:



        
3条回答
  •  心在旅途
    2021-01-07 16:52

    I can't speak for the full performance implications, but v + &s will work on beta, which I believe is just similar to pushing each value onto the original Vec.

提交回复
热议问题