diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-10-05 17:57:30 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-10-05 17:57:30 +0200 |
| commit | 5e06941c63425ab10e08e4d533939c7309cfe6ce (patch) | |
| tree | 3cce4e64aca86b782e861bb92ad663ee707e42d9 /src/eval | |
| parent | 00be5d36c4f5bdc39a5f94ae1eb200499ffb8871 (diff) | |
Iterate over grapheme clusters instead of chars
Diffstat (limited to 'src/eval')
| -rw-r--r-- | src/eval/str.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/eval/str.rs b/src/eval/str.rs index 59e0887a..800d1709 100644 --- a/src/eval/str.rs +++ b/src/eval/str.rs @@ -3,6 +3,8 @@ use std::convert::TryFrom; use std::fmt::{self, Debug, Formatter, Write}; use std::ops::{Add, AddAssign, Deref}; +use unicode_segmentation::UnicodeSegmentation; + use crate::diag::StrResult; use crate::util::EcoString; @@ -41,9 +43,9 @@ impl Str { self.0.as_str() } - /// Return an iterator over the chars as strings. + /// Return an iterator over the grapheme clusters as strings. pub fn iter(&self) -> impl Iterator<Item = Str> + '_ { - self.chars().map(Into::into) + self.graphemes(true).map(Into::into) } /// Repeat this string `n` times. |
