Skip to content

Commit b455878

Browse files
committed
Fix: Add missing negation
If we emit a ReadUntil::NBytes, but the `eof` flag is already set and the buffer is indeed _not_ empty, we return Some() here. If the buffer is empty, there's nothing to return, so we return None. This fixes the following tests: * reader::tests::test_any_with_multiple_possible_matches * reader::tests::test_any_with_same_start_different_length * reader::tests::test_eof * reader::tests::test_expect_melon * reader::tests::test_nbytes * reader::tests::test_regex * reader::tests::test_regex2 Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
1 parent 9e8a768 commit b455878

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/reader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn find(needle: &ReadUntil, buffer: &str, eof: bool) -> Option<(usize, usize
7575
ReadUntil::NBytes(n) => {
7676
if *n <= buffer.len() {
7777
Some((0, *n))
78-
} else if eof && buffer.is_empty() {
78+
} else if eof && !buffer.is_empty() {
7979
// reached almost end of buffer, return string, even though it will be
8080
// smaller than the wished n bytes
8181
Some((0, buffer.len()))

0 commit comments

Comments
 (0)