harper_core/
char_string.rs1use smallvec::SmallVec;
2
3pub type CharString = SmallVec<[char; 12]>;
6
7pub trait CharStringExt {
9 fn to_lower(&self) -> CharString;
10 fn to_string(&self) -> String;
11}
12
13impl CharStringExt for [char] {
14 fn to_lower(&self) -> CharString {
15 let mut out = CharString::with_capacity(self.len());
16
17 out.extend(self.iter().flat_map(|v| v.to_lowercase()));
18
19 out
20 }
21 fn to_string(&self) -> String {
22 self.iter().collect()
23 }
24}
25
26macro_rules! char_string {
27 ($string:literal) => {{
28 use crate::char_string::CharString;
29
30 $string.chars().collect::<CharString>()
31 }};
32}
33
34pub(crate) use char_string;