exercism-solutions/rust/reverse-string/src/lib.rs

9 lines
229 B
Rust

use unicode_segmentation::UnicodeSegmentation;
pub fn reverse(input: &str) -> String {
if cfg!(feature = "grapheme") {
input.graphemes(true).rev().collect()
} else {
input.chars().rev().collect()
}
}