Learning from YayoDrayber, I am sharing my CodeWars Kata which could also be a reference for myself in the future.
DESCRIPTION:
Complete the solution so that it reverses the string passed into it.
'world' => 'dlrow'
'word' => 'drow'
Starting code
fn solution(phrase: &str) -> String {
unimplemented!();
}
My attempt
fn solution(phrase: &str) -> String {
phrase.chars().rev().collect::<String>()
}
Best Practice
fn solution(phrase: &str) -> String {
phrase.chars().rev().collect()
}
Shorter Code
fn solution(phrase: &str) -> String {
phrase.rsplit("").collect::<String>()
}
My postkata snippet
fn reverse_string(phrase: &str) -> String {
phrase.rsplit("").collect()
}