diff options
Diffstat (limited to 'third_party/rust/clap/src/strext.rs')
-rw-r--r-- | third_party/rust/clap/src/strext.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/third_party/rust/clap/src/strext.rs b/third_party/rust/clap/src/strext.rs new file mode 100644 index 0000000000..6f81367ab2 --- /dev/null +++ b/third_party/rust/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, + } + } +} |