Add try_seek to seek when possible

Signed-off-by: trivernis <trivernis@protonmail.com>
master
trivernis 4 years ago
parent 89a866cb92
commit 0c003fe278
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

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

@ -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 /// Seeks any character of the given group until none is encountered anymore
pub fn seek_any(&mut self, chars: &[char]) -> TapeResult<()> { pub fn seek_any(&mut self, chars: &[char]) -> TapeResult<()> {
while self.check_any(chars) { while self.check_any(chars) {

Loading…
Cancel
Save