Closed lauti7 closed 1 year ago
Hi, I'm opening up this issue because in this chapter (Vec from scratch), the code example at the end of the page has one comments which say:
// This can't overflow since self.cap <= isize::MAX.
I think the above comment is wrong because self.cap is an usize type so actually it can be greater than isize::MAX.
self.cap
usize
isize::MAX
Is this actually wrong or am I misunderstanding something? Hope you can help me out.
There is an invariant enforced by an assert just a few lines below that it cannot be over isize::MAX.
Thank you
Hi, I'm opening up this issue because in this chapter (Vec from scratch), the code example at the end of the page has one comments which say:
I think the above comment is wrong because
self.cap
is anusize
type so actually it can be greater thanisize::MAX
.Is this actually wrong or am I misunderstanding something? Hope you can help me out.