From 433d41297c4a3ffec8c47c4cef2697b5d41eebe4 Mon Sep 17 00:00:00 2001 From: trivernis Date: Wed, 29 Jul 2020 20:30:43 +0200 Subject: [PATCH] Add err function for easier error creation --- Cargo.toml | 2 +- src/tapemachine.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d26458f..19f575a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "charred" -version = "0.1.5" +version = "0.1.6" authors = ["trivernis "] edition = "2018" license-file = "LICENSE" diff --git a/src/tapemachine.rs b/src/tapemachine.rs index c5786c3..52bd991 100644 --- a/src/tapemachine.rs +++ b/src/tapemachine.rs @@ -48,14 +48,22 @@ impl CharTapeMachine { } } + #[inline] pub fn get_text(&self) -> Vec { self.text.clone() } + #[inline] pub fn get_index(&self) -> usize { self.index } + /// Creates an error at the current position + #[inline] + pub fn err(&self) -> TapeError { + TapeError::new(self.index) + } + /// Returns the next char /// if there is any pub fn next_char(&mut self) -> Option {