Created
December 31, 2019 09:35
-
-
Save daneb/16f4b51c53c9e73b9207ec72eef73b3e to your computer and use it in GitHub Desktop.
Ownership in Rust with Pluralize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let s = String::from("book"); | |
// Add code here that calls the pluralize function | |
let many = pluralize(s.clone()); | |
println!( | |
"I have one {}, you have two {}", | |
s, | |
many, | |
); | |
} | |
// Add appropriate parameters, return values, and implementation to this function | |
fn pluralize(mut a_string : String) -> String | |
{ | |
a_string.push('s'); | |
a_string | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment