Day 2 - Memory doesn't grow on Christmas trees 🎄

“Alright, Bernard,” Santa said, locking eyes with the elf. “I thought you were one of the good ones. I even considered giving you a share in the sleigh’s IPO. But THIS?!” He waved the paper like it was a subpoena. "The function you defined yesterday takes ownership of the message, now the reindeer and the other elves are cloning like it's a Black Friday sale! Memory doesn’t grow on Christmas trees, Bernard!”

"This API is TRASH!" Santa bellowed!

fn main(){
    let message = String::from("Ho ho ho! Merry Christmas!");
    attach_message_to_present(message.clone());
    println!("{}", message);
}

Prancer trotted by with a scowl. "We shouldn't have used Rust in the first place. This is what we get for trying to be fancy,"


Your Task

Santa’s right (as always, he’s Santa). The function takes ownership of the String, you should update the function signature to accept a reference instead of owning the value. This way we don't need to clone the message and can just borrow it.

Hints

Here is a hint to help you solve the challenge

Click here to see the hint

To use a reference, you can either use &String or &str as the function parameter type.

pub fn attach_message_to_present(message: &String) {
    println!("The present now has this message: {}", message);
}