Hello Rustacean
Level: intro (score: 1)
🚀 These intro exercises are prep for our
Rust Intro Cohort Program.
Welcome to Rust! 🦀
Let’s kick things off with the classic — print a greeting!
But instead of just printing, we’ll make a proper function that returns a String
. No parameters yet, just returning a hardcoded message.
✅ Your task:
Implement the greet
function to return "Hello, Rustacean!"
as an owned String
. We'll learn about borrowing and ownership in a later Bite.
Use .to_string()
or "..."
.into() — either is fine.
Future bites will add logic, parameters, and match statements — but first things first.
pub fn greet() -> String {
// your code here
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_greet() {
assert_eq!(greet(), "Hello, Rustacean!".to_string());
}
}