From 0c003fe278d36b015b9a7133602e9ea0751262ea Mon Sep 17 00:00:00 2001 From: trivernis Date: Thu, 21 Jan 2021 20:27:45 +0100 Subject: [PATCH] Add try_seek to seek when possible Signed-off-by: trivernis --- Cargo.toml | 2 +- src/tapemachine.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 76687b5..bba781f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "charred" -version = "0.3.4" +version = "0.3.5" authors = ["trivernis "] edition = "2018" license-file = "LICENSE" diff --git a/src/tapemachine.rs b/src/tapemachine.rs index b8d963b..4f4cf39 100644 --- a/src/tapemachine.rs +++ b/src/tapemachine.rs @@ -118,6 +118,13 @@ impl CharTapeMachine { } } + /// Seeks one character and returns + /// if it seeked or an error occurred + #[inline] + pub fn try_seek(&mut self) -> bool { + self.seek_one().is_ok() + } + /// Seeks any character of the given group until none is encountered anymore pub fn seek_any(&mut self, chars: &[char]) -> TapeResult<()> { while self.check_any(chars) {