A minimal byte-by-byte reader for parsing input.
```rust use byte_reader::Reader;
fn main() {
// Get a &[u8]
or Vec<u8>
input from
// a File, standard input, or something
let sampleinput = "Hello, bytereader!".as_bytes();
// Create a mutable `r`
let mut r = Reader::new(sample_input);
// Use some simple operations
// to parse the input
r.consume("Hello").unwrap();
r.consume(",").unwrap();
r.skip_whitespace();
let name = r.read_snake().unwrap(); // byte_reader
r.consume("!").unwrap();
println!("Greeted to `{name}`.");
} ```
And, with location
feature, you can track the reader's parsing location ( line and column ) in the input bytes :
``rust
/* enable
location` feature */
use byte_reader::Reader;
fn main() { let sampleinput = "Hello, bytereader!".as_bytes();
let mut r = Reader::new(sample_input);
r.consume("Hello").unwrap();
r.consume(",").unwrap();
r.skip_whitespace();
let name_line = r.line(); // 1
let name_column = r.column(); // 11
let name = r.read_snake().unwrap(); // byte_reader
r.consume("!").unwrap();
println!("Greeted to `{name}`.");
println!("In the input, the name starts at column {name_column} of line {name_line}");
} ```