Skip to content

Instantly share code, notes, and snippets.

@daneb
Created December 31, 2019 09:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daneb/16f4b51c53c9e73b9207ec72eef73b3e to your computer and use it in GitHub Desktop.
Save daneb/16f4b51c53c9e73b9207ec72eef73b3e to your computer and use it in GitHub Desktop.
Ownership in Rust with Pluralize
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