-
-
Save rust-play/cce43d9ebf68e3399a414979ff9090eb to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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"); | |
let ss = pluralize(s.clone()); | |
println!("One {}, many {}", s, ss); | |
} | |
fn pluralize(s: String) -> String { | |
// Can't push_str directly onto s as s is not mutable | |
let mut p = s; | |
p.push_str("s"); | |
return p | |
// This is ok | |
// s + "s" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment