Skip to content

Commit e7d4fed

Browse files
committed
Remove the special-case for reading 0 bytes and add comments.
1 parent dceefcb commit e7d4fed

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/io/streams.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ impl AsyncRead for AsyncInputStream {
4040
// Ideally, the ABI would be able to read directly into buf. However, with the default
4141
// generated bindings, it returns a newly allocated vec, which we need to copy into buf.
4242
let read = match self.stream.read(buf.len() as u64) {
43-
// 0 bytets from WASI's `read` just means we got zero bytes.
44-
Ok(r) if r.is_empty() => {
45-
return Err(std::io::Error::from(std::io::ErrorKind::Interrupted))
46-
}
43+
// We don't need to special-case 0 here: a value of 0 bytes from
44+
// WASI's `read` doesn't mean end-of-stream as it does in Rust,
45+
// however since we called `self.ready()`, we'll always get at
46+
// least one byte.
4747
Ok(r) => r,
4848
// 0 bytes from Rust's `read` means end-of-stream.
4949
Err(StreamError::Closed) => return Ok(0),

0 commit comments

Comments
 (0)