Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

String Length

Write a function called print_length that borrows a String and prints its length. Call it from main, then print the string itself to show it's still valid.

Expected output:

text
Length: 11
Word: programming

Hints:

  • Use fn print_length(text: &String) to borrow
  • Use text.len() to get the length
  • The string "programming" has 11 characters
rust
fn main() {
}