Skip to content

Commit

Permalink
Fixing benchmarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheVeryDarkness committed Oct 12, 2024
1 parent d354d18 commit 1c0de4e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions benches/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ struct LazyWriter(std::ops::Range<i32>);
impl Read for LazyWriter {
fn read(&mut self, mut buf: &mut [u8]) -> io::Result<usize> {
if let Some(num) = self.0.next() {
let s = format!("{} ", num);
Ok(buf.write(s.as_bytes())?)
let s = format!(" {}", num);
if buf.len() >= s.len() {
buf.write_all(s.as_bytes())?;
Ok(s.len())
} else {
buf.write_all(b" ")?;
Ok(1)
}
} else {
Ok(0)
}
Expand Down

0 comments on commit 1c0de4e

Please sign in to comment.