Skip to content
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

Move IntoByteSlice[Mut]: Into into methods #1299

Merged
merged 1 commit into from
May 18, 2024
Merged

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented May 18, 2024

Remove the Into<&[u8]> and Into<&mut [u8]> bounds on IntoByteSlice and IntoByteSliceMut and replace them with methods. This allows IntoByteSlice to be implemented for &mut [u8] (and, as a consequence, permits Ref::<&mut [u8], _>::into_ref), which was previously barred.

Closes #1260

@joshlf joshlf requested a review from jswrenn May 18, 2024 18:36
@joshlf joshlf enabled auto-merge May 18, 2024 18:36
@codecov-commenter
Copy link

codecov-commenter commented May 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.86%. Comparing base (1c77a9d) to head (4f92091).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1299      +/-   ##
==========================================
+ Coverage   87.79%   87.86%   +0.06%     
==========================================
  Files          15       15              
  Lines        5171     5199      +28     
==========================================
+ Hits         4540     4568      +28     
  Misses        631      631              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Remove the `Into<&[u8]>` and `Into<&mut [u8]>` bounds on `IntoByteSlice`
and `IntoByteSliceMut` and replace them with methods. This allows
`IntoByteSlice` to be implemented for `&mut [u8]` (and, as a
consequence, permits `Ref::<&mut [u8], _>::into_ref`), which was
previously barred.

Closes #1260
unsafe impl<'a> IntoByteSlice<'a> for &'a [u8] {
#[inline(always)]
fn into_byte_slice(self) -> &'a [u8] {
// SAFETY: It would be patently insane to implement `<Deref for
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

@joshlf joshlf added this pull request to the merge queue May 18, 2024
Merged via the queue into main with commit d1d416d May 18, 2024
210 checks passed
@joshlf joshlf deleted the into-byte-slice-method branch May 18, 2024 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Into<&[u8]> bound from IntoByteSlice?
3 participants