Skip to content

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
@joshlf joshlf force-pushed the into-byte-slice-method branch from 1e4cc98 to 877af9f Compare May 18, 2024 18:43
@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
@joshlf joshlf force-pushed the into-byte-slice-method branch from 877af9f to 4f92091 Compare May 18, 2024 19:08
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
@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