[Solved] Proper way to access Vec as strings [duplicate]


Because r is an array of u8, you need to convert it to a valid &str and use push_str method of String.

use std::str;

fn main() {
    let rfrce = vec![&[65,66,67], &[68,69,70]];

    let mut str = String::new();

    for r in rfrce {
        str.push_str(str::from_utf8(r).unwrap());
    }

    println!("{}", str);
}

Rust Playground

3

solved Proper way to access Vec<&[u8]> as strings [duplicate]