-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Add RingBuf::as_slices as per collections reform v2. #19903
Conversation
@@ -76,7 +76,13 @@ impl<T> Default for RingBuf<T> { | |||
impl<T> RingBuf<T> { | |||
/// Turn ptr into a slice | |||
#[inline] | |||
unsafe fn buffer_as_slice(&self) -> &[T] { | |||
unsafe fn buffer_as_slice<'a>(&'a self) -> &'a [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.
Why add the lifetimes?
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's implemented with transmute with no lifetime annotations. It seems safer this way.
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.
Mmm... sweet, sweet elision paranoia. :)
Let's please hold off merging this until rust-lang/rfcs#509 is merged as well (but review is fine!) |
RFC 509 has landed. Let's merge this sucker! |
let expected_right: Vec<_> = range(cap+1, cap+2).collect(); | ||
assert_eq!(left, expected_left); | ||
assert_eq!(right, expected_right); | ||
} |
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.
Actually, it occurs to me: can't you make this test capacity agnostic by just doing push_back()x2, push_front()x2? Or are you testing some particular edge cases?
This LGTM now. r=me whether you change the test or not; your call on which way you prefer. |
See: rust-lang/rfcs#509 Not sure if this is allowed to land before the RFC. Either way, it's here for review. r? @gankro cc: @bfops
69c60c2
to
525f65e
Compare
See: rust-lang/rfcs#509 Not sure if this is allowed to land before the RFC. Either way, it's here for review. r? @gankro cc: @bfops
See: rust-lang/rfcs#509
Not sure if this is allowed to land before the RFC. Either way,
it's here for review.
r? @gankro
cc: @bfops