RustArena

Step 3 of 6

Several lines, and print! versus println!

Each println! prints its text and then a newline, so the next output starts on a fresh line. Its sibling print! prints the text without ending the line:

fn main() {
    print!("Ready, ");
    print!("set, ");
    println!("go!");
    println!("Next line");
}
Ready, set, go!
Next line

Escape sequences

Some characters can't be typed directly inside a string, so they're written with a backslash \. These are escape sequences:

You write You get
\n a newline
\t a tab
\" a double quote (without ending the string)
\\ one backslash
fn main() {
    println!("Line one\nLine two");
    println!("She said \"hi\"");
}
Line one
Line two
She said "hi"

Your task

Print these three lines, using one println! with \n escapes in it:

Rust
is
fast

Challenge 2

Print exactly this line, including the double quotes:

The crab said "hello"

Challenge 3

Use print! three times and println! once (in that order) to print 1, 2, 3, go! on one line.

Previous: Printing your own text Next: Printing values with {}