Fix unsafe unwrap in rewind

master
trivernis 4 years ago
parent e316d063f8
commit 5712ec2320

@ -1,6 +1,6 @@
[package]
name = "charred"
version = "0.2.1"
version = "0.2.2"
authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018"
license-file = "LICENSE"

@ -91,8 +91,10 @@ impl CharTapeMachine {
/// Rewinds to a given index
#[inline]
pub fn rewind(&mut self, index: usize) {
self.index = index;
self.current_char = *self.text.get(index).unwrap();
if self.text.len() > index {
self.index = index;
self.current_char = *self.text.get(index).unwrap();
}
}
/// Rewinds to a given index and returns an error

Loading…
Cancel
Save