Skip to content

why using rfind_byte in line_buffer.rs #2342

Answered by BurntSushi
baoti asked this question in Q&A
Discussion options

You must be logged in to vote

Judging by your failing test case, my guess is that you might be misunderstanding what a LineBuffer is. It is not a buffer for holding a single line, but rather a sequence of complete lines. That's what this comment is referring to:

// At this point, if we couldn't find a line terminator, then we
// don't have a complete line. Therefore, we try to read more!

Namely, a LineBuffer guarantees that its buffer contains at least one complete line. How does the buffer determine whether it has a complete line or not? That only occurs when either a line terminator is seen or when EOF is reached.

But the k…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by baoti
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants