Implement Seek::stream_position() for BufReader#74366
Implement Seek::stream_position() for BufReader#74366bors merged 1 commit intorust-lang:masterfrom t-rapp:tr-bufreader-pos
Conversation
|
r? @kennytm (rust_highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
LukasKalbertodt
left a comment
There was a problem hiding this comment.
Looks mostly good to me! Only thing I noticed is that the subtraction might underflow if the inner reader has a buggy stream_position implementation. Not sure if we really need to harden against that. But I think I would prefer, for now, if you could replace the subtraction with:
pos.checked_sub(...).expect("buggy `stream_position` implementation in inner reader of BufReader")Or something like that.
|
Updated the implementation to check for subtraction underflow / overflow. Realized that besides a buggy inner reader, this situation can also occur when misusing the (unfortunately public) |
LukasKalbertodt
left a comment
There was a problem hiding this comment.
Sorry for the delay. But looks almost ready to merge now! Just a tiny thing I noticed.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
LukasKalbertodt
left a comment
There was a problem hiding this comment.
Oops, I found another minor thing °_°
Sorry for not noticing that in my last review.
|
Looks good to me! @bors r+ Thanks for sticking with this PR for so long! :) |
|
📌 Commit 246d327 has been approved by |
|
☀️ Test successful - checks-actions, checks-azure |
Optimization over
BufReader::seek()for getting the current position without flushing the internal buffer.Related to #31100. Based on the code in #70577.