Rust Echo Command Implementation I'm just starting out in Rust and I find the concept of ownership confusing so I wrote an implementation of the echo command. I would like to know if I could have set the initial value on the echo variable any better or just any general improvements.

use std::env;

fn main() {
    let args: Vec&lt;String&gt; = env::args().collect();

    let mut echo: String;
    if let Some(string) = args.get(1) {
        echo = string.to_string();
    } else {
        return;
    }

    for arg in &amp;args[2..] {
        echo.push(' ');
        echo.push_str(arg.as_str());
    }
    echo.push('\n');

    println!("{}", echo);
}
I would not say I am any more proficient but I would make these changes if I wrote it.


skip(1) first arg.
join(" ") instead of iterate though args. 


You do not need a mutable value. 

use std::env;

fn main() {
    let args: Vec&lt;String&gt; = env::args().skip(1).collect();

    if args.len() == 0 {
        println!("");
    } else {
        println!("{}", args.join(" "));
    }
}


I would do one more thing and send to stdout since your mimicking echo, but maybe much for this answer.