|
25 | 25 | /// // ...get new chunk of data |
26 | 26 | /// assert_eq!(parser.feed(b" with = 'some > and ?"), None); |
27 | 27 | /// // ...get another chunk of data |
28 | | -/// assert_eq!(parser.feed(b"' inside?>and the text follow..."), Some(10)); |
29 | | -/// // ^ ^ |
30 | | -/// // 0 10 |
| 28 | +/// assert_eq!(parser.feed(b"' inside?>and the text follow..."), Some(9)); |
| 29 | +/// // ^ ^ |
| 30 | +/// // 0 9 |
31 | 31 | /// ``` |
32 | 32 | /// |
33 | 33 | /// [`feed`]: Self::feed() |
@@ -57,10 +57,9 @@ impl PiParser { |
57 | 57 | for i in memchr::memchr_iter(b'>', bytes) { |
58 | 58 | match i { |
59 | 59 | // +1 for `>` which should be included in event |
60 | | - 0 if self.0 => return Some(1), |
| 60 | + 0 if self.0 => return Some(0), |
61 | 61 | // If the previous byte is `?`, then we found `?>` |
62 | | - // +1 for `>` which should be included in event |
63 | | - i if i > 0 && bytes[i - 1] == b'?' => return Some(i + 1), |
| 62 | + i if i > 0 && bytes[i - 1] == b'?' => return Some(i), |
64 | 63 | _ => {} |
65 | 64 | } |
66 | 65 | } |
@@ -95,11 +94,11 @@ fn pi() { |
95 | 94 | assert_eq!(parse_pi(b"?", true), Err(true)); // ?|? |
96 | 95 |
|
97 | 96 | assert_eq!(parse_pi(b">", false), Err(false)); // x|> |
98 | | - assert_eq!(parse_pi(b">", true), Ok(1)); // ?|> |
| 97 | + assert_eq!(parse_pi(b">", true), Ok(0)); // ?|> |
99 | 98 |
|
100 | | - assert_eq!(parse_pi(b"?>", false), Ok(2)); // x|?> |
101 | | - assert_eq!(parse_pi(b"?>", true), Ok(2)); // ?|?> |
| 99 | + assert_eq!(parse_pi(b"?>", false), Ok(1)); // x|?> |
| 100 | + assert_eq!(parse_pi(b"?>", true), Ok(1)); // ?|?> |
102 | 101 |
|
103 | | - assert_eq!(parse_pi(b">?>", false), Ok(3)); // x|>?> |
104 | | - assert_eq!(parse_pi(b">?>", true), Ok(1)); // ?|>?> |
| 102 | + assert_eq!(parse_pi(b">?>", false), Ok(2)); // x|>?> |
| 103 | + assert_eq!(parse_pi(b">?>", true), Ok(0)); // ?|>?> |
105 | 104 | } |
0 commit comments