String to byte iterator that owns the String

Hello,

I need to convert a String to an Iterator<Item=u8>. String::bytes(&self) doesn't work for me, because it only borrows the String, whcih is left behind and does not live long enough. Is there a way to convert a String to an Iterator<Item=u8> that owns the String? Thanks!

Best, Oliver

Convert the String to a Vec<u8> first.

s.into_bytes().into_iter()

Awesome, thanks!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.