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

10 lines
229 B
Rust
Raw Normal View History

2023-10-11 10:56:50 -05:00
use unicode_segmentation::UnicodeSegmentation;
2023-10-11 10:40:58 -05:00
pub fn reverse(input: &str) -> String {
2023-10-11 10:56:50 -05:00
if cfg!(feature = "grapheme") {
input.graphemes(true).rev().collect()
} else {
input.chars().rev().collect()
}
2023-10-11 10:40:58 -05:00
}