# leftover
[<img alt="github" src="https://img.shields.io/badge/github-WangLabCSU/leftover-8da0cb?style=for-the-badge&labelColor=555555&logo=github" height="20">](https://github.com/WangLabCSU/leftover)
[<img alt="crates.io" src="https://img.shields.io/crates/v/leftover.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/leftover)
[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-leftover-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs" height="20">](https://docs.rs/leftover)
[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/WangLabCSU/leftover/ci.yml?branch=main&style=for-the-badge" height="20">](https://github.com/WangLabCSU/leftover/actions?query=branch%3Amain)
`leftover` is a `BufRead` adapter that keeps partial data available across buffer
boundaries.
```rust
use std::io::BufReader;
use leftover::LeftoverReader;
let input = BufReader::with_capacity(3, b"hello\n".as_slice());
let mut reader = LeftoverReader::new(input);
// Copy the incomplete line into the leftover before reading more.
reader.fill_view().unwrap().accumulate();
let view = reader.fill_view().unwrap();
assert_eq!(view.leftover(), b"hel");
assert_eq!(view.buffer(), b"lo\n");
// Take the saved prefix together with three bytes from the current chunk.
assert_eq!(view.take_view(3), b"hello\n");
```