-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
io: add a BufferedWriter and supporting methods #22265
Conversation
oops. I messed up the rebase. |
8f04db7
to
8cb24cc
Compare
8cb24cc
to
b826fb1
Compare
Signed-off-by: Einar Hjortdal <einar.hjortdal@outlook.com>
drop `arrays.concat` in favor of `<<` Co-authored-by: Delyan Angelov <delian66@gmail.com> Signed-off-by: Einar Hjortdal <einar.hjortdal@outlook.com>
Signed-off-by: Einar Hjortdal <einar.hjortdal@outlook.com>
Signed-off-by: Einar Hjortdal <einar.hjortdal@outlook.com>
b826fb1
to
029dc8b
Compare
Test is failing sometimes, I think I wrote a bad utility function in the test and just discovered it. |
The windows CI failures are unrelated and are already fixed on master. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work.
I could not think about any other tests.
import io | ||
import rand | ||
|
||
struct ArrayWriter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct ArrayWriter { | |
struct ArrayWriter implements Writer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although that could wait a bit more 🤔
n := b.wr.write(b.buf[0..b.n])! | ||
if n < b.n { | ||
return error('Writer accepted less bytes than expected without returning any explicit error.') | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could perhaps loop here, till everything is flushed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or there could be a separate flush_all method that does it 🤔
Address #21975