Fix a panic in `cooked_byte` on utf-8 chars
Don't want to slice on the wrong boundary!
Closes #54
diff --git a/src/stable.rs b/src/stable.rs
index 6312ace..ffa077a 100644
--- a/src/stable.rs
+++ b/src/stable.rs
@@ -904,7 +904,13 @@
};
if ok {
match bytes.next() {
- Some((offset, _)) => Ok((input.advance(offset), ())),
+ Some((offset, _)) => {
+ if input.chars().as_str().is_char_boundary(offset) {
+ Ok((input.advance(offset), ()))
+ } else {
+ Err(LexError)
+ }
+ }
None => Ok((input.advance(input.len()), ())),
}
} else {