Today's tip: From Hello, World to hired.

Courses / Rust: Ownership without Tears / Lesson 1

1. Hello, Cargo

Every programmer starts here. In this lesson you write a complete program, run it, and change it until it does what you want.

Borrowing and referencesrust
fn longest(words: &[String]) -> &str {
    let mut best = "";
    for w in words {
        if w.len() > best.len() {
            best = w;
        }
    }
    best
}

Your turn

Change the program so it greets you by name, then run it in the playground. The checks turn green when the output matches.

Open the playground Next lesson →