sbircio 0.1.0

A lightweight, Unicode-aware BufRead wrapper with peek-ahead for building parsers and lexers
Documentation
use sbircio::Input;
use std::io::Cursor;

fn main() -> Result<(), sbircio::InputError> {
    let source = Cursor::new("42 + hello");
    let mut input = Input::new(source);

    // Read a number token
    let num = input.consume_while(|c| c.is_ascii_digit())?;
    input.skip_whitespace()?;

    // Verify an operator
    input.expect("+")?;
    input.skip_whitespace()?;

    // Read an identifier
    let word = input.consume_while(|c| c.is_alphabetic())?;

    println!("{num} + {word}"); // 42 + hello
    Ok(())
}