Printing Quotes

Challenge

Prompt for a quote and an author's name. Display the author's name and then the quote inside quotation marks.

Solution

The main purpose of this exercise is to create strings containing character escapes. Knowing character escapes, the solution is simple:

use std::io;

fn main() -> io::Result<()> {
    println!("What is the quote?");
    let mut inputs = io::stdin().lines();
    let quote = inputs.next().expect("No quote provided")?;

    println!("Who said it?");
    let author = inputs.next().expect("No author provided")?;

    println!("{} says, \"{}\"", author, quote);

    Ok(())
}

Sample output:

What is the quote?
51% of quotes on the Internet are fake.
Who said it?
Me
Me says, "51% of quotes on the Internet are fake."

Of course, there are other escape sequences, for instance:

#![allow(unused)]
fn main() {
println!("\"\nI\u{2764}\u{FE0F}\u{1F1FB}\u{1F1F3}\r\"")
}

This code snippet prints

"
I❤️🇻🇳
"