Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-ops/src/chunked_array/strings/reverse.rs
6939 views
1
use polars_core::prelude::StringChunked;
2
use polars_core::prelude::arity::unary_elementwise;
3
use unicode_reverse::reverse_grapheme_clusters_in_place;
4
5
fn to_reverse_helper(s: Option<&str>) -> Option<String> {
6
s.map(|v| {
7
let mut text = v.to_string();
8
reverse_grapheme_clusters_in_place(&mut text);
9
text
10
})
11
}
12
13
pub fn reverse(ca: &StringChunked) -> StringChunked {
14
unary_elementwise(ca, to_reverse_helper)
15
}
16
17