Closed YichiZhang0613 closed 4 months ago
Hi @YichiZhang0613, thanks for opening this issue! Can you clarify what the inconsistency is between the documentation and implementation? The docs indicate that an out-of-bounds range will cause a panic. These methods were written for a specific internal use case and all of the places from which they're called should be using safe ranges. Have you encountered a panic from this code?
Hi @YichiZhang0613, thanks for opening this issue! Can you clarify what the inconsistency is between the documentation and implementation? The docs indicate that an out-of-bounds range will cause a panic. These methods were written for a specific internal use case and all of the places from which they're called should be using safe ranges. Have you encountered a panic from this code?
I read the code and found that the document pointed out that panic will occur when the range is out of bounds. In order to avoid unnecessary panic, you should check whether the array is out of bounds(using get()) in the code before using it instead of calling buffer[range] directly.
Hey @YichiZhang0613, I discussed this with the team and we are not concerned about panicking in this situation. The bounds used are safe and we prefer the convenience of not needing to handle an error that should never occur. I'm going to close this out, but please let us know if you have any further questions or feedback.
I noticed possible panics due to inconsistency between documentation and code implementation in bson-rust/src/raw/serde/seeded_visitor.rs The code does not check whether range is out of bounds before using range.