aboutsummaryrefslogtreecommitdiff
path: root/clap/src/strext.rs
diff options
context:
space:
mode:
Diffstat (limited to 'clap/src/strext.rs')
-rw-r--r--clap/src/strext.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/clap/src/strext.rs b/clap/src/strext.rs
new file mode 100644
index 0000000..6f81367
--- /dev/null
+++ b/clap/src/strext.rs
@@ -0,0 +1,16 @@
+pub trait _StrExt {
+ fn _is_char_boundary(&self, index: usize) -> bool;
+}
+
+impl _StrExt for str {
+ #[inline]
+ fn _is_char_boundary(&self, index: usize) -> bool {
+ if index == self.len() {
+ return true;
+ }
+ match self.as_bytes().get(index) {
+ None => false,
+ Some(&b) => b < 128 || b >= 192,
+ }
+ }
+}