Skip to content

Commit cf385b5

Browse files
committed
Fix usage of split_inclusive in event parser logic
It was relying on old behavior where Some(empty slice) would be returned if there were no matches. This was updated in more recent rust versions to return None, but CircleCI was using a much older version of rust than I have locally. Updated the usage and CircleCI config to use cimg/rust.
1 parent a2cffbe commit cf385b5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

eventsource-client/src/event_parser.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,14 @@ impl EventParser {
288288
// * the first line should be appended to the incomplete line, if any
289289

290290
if let Some(incomplete_line) = self.incomplete_line.as_mut() {
291-
let line = lines.next().expect("Should not be none!");
292-
// split always returns at least one item
293-
trace!(
294-
"extending line from previous chunk: {:?}+{:?}",
295-
logify(incomplete_line),
296-
logify(line)
297-
);
291+
if let Some(line) = lines.next() {
292+
trace!(
293+
"extending line from previous chunk: {:?}+{:?}",
294+
logify(incomplete_line),
295+
logify(line)
296+
);
298297

299-
self.last_char_was_cr = false;
300-
if !line.is_empty() {
298+
self.last_char_was_cr = false;
301299
// Checking the last character handles lines where the last character is a
302300
// terminator, but also where the entire line is a terminator.
303301
match line.last().unwrap() {

0 commit comments

Comments
 (0)