I'm trying to solve a Kata where I'm asked to "count sheep". A function count_sheep
is called with a positive integer as parameter. I'm supposed to return a string with a murmur: "1 sheep...2 sheep...3 sheep..."
This is what I have so far:
fn count_sheep(n: u32) -> String {
let mut Sheep_vec = String::new();
let mut i = 1;
while i <= n {
sheep_string = ("{} sheep..", i);
Sheep_vec.push(sheep_string);
i = i + 1;
}
Sheep_vec
}
I wanted to return the string analog to the println!
macro, but that fails, because .push()
doesn't support multiple argumentss.