Adding Strings to vec


I want to create a vec of Strings. Then just wait for the user input tot fill the vec.

fn main() {
    let stdin = io::stdin();
    let mut new_list: Vec<String> = Vec::new();
    for line in stdin.lock().lines() {
        let mut newInput = line.unwrap();
        println!("{}", newInput);


The error I get from this is expected &mut Vec<String>, found struct String on the append line.
How can I fix this?

You need to use push instead of append.

1 Like

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.