-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add lifetime bounds on Items and MutItems. #16993
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
Conversation
let ptr = self.ptr; | ||
let cap = self.cap; | ||
let begin = self.ptr as *const T; | ||
let end = (self.ptr as uint + self.len()) as *const T; |
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.
It may be somewhat important for this to stay as pointers for non-zero sized types, since casting to integers loses optimisation information, e.g.
let end = if mem::size_of::<T>() == 0 {
(p as uint + self.len()) as *const T
} else {
p.offset(self.len() as int)
};
I would be very interested in seeing this not reencode the iteration, but I guess this may not be possible.
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.
Thanks for the response. I've gone ahead and made the change. My first pass at fixing this issue involved making an UnsafeItems struct which could be used to implement Items, MutItems, and Vec's MoveItems. But on second thought it seemed a bit unnecessary to create a new public struct which had very few uses.
If this is desirable, I'd be happy to implement it that way.
@huonw is this good to go? |
Can you add a test for Thanks! (Sorry it's taken so long.) |
This also requires a fix for Vec's MoveItems. This resolves issue rust-lang#16941
Looking at this now. I assume you want me to rebase to master which causes a few more things to break. |
95527be
to
49e593c
Compare
I've updated the pull request to work off the latest commits. In the interim - this fix also affected the new btree implementation |
This also required a fix for Vec's MoveItems. This resolves issue #16941