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

Renamed as_bytes_mut to as_mut_bytes #870

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/byteorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ mod tests {
for _ in 0..RAND_ITERS {
let native = T::Native::rand(&mut r);
let mut bytes = T::ByteArray::default();
bytes.as_bytes_mut().copy_from_slice(native.as_bytes());
bytes.as_mut_bytes().copy_from_slice(native.as_bytes());
if invert {
bytes = bytes.invert();
}
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,7 @@ pub unsafe trait IntoBytes {

/// Gets the bytes of this value mutably.
///
/// `as_bytes_mut` provides access to the bytes of this value as a mutable
/// `as_mut_bytes` provides access to the bytes of this value as a mutable
/// byte slice.
///
/// # Examples
Expand All @@ -2760,7 +2760,7 @@ pub unsafe trait IntoBytes {
/// checksum: [6, 7],
/// };
///
/// let bytes = header.as_bytes_mut();
/// let bytes = header.as_mut_bytes();
///
/// assert_eq!(bytes, [0, 1, 2, 3, 4, 5, 6, 7]);
///
Expand All @@ -2774,7 +2774,7 @@ pub unsafe trait IntoBytes {
/// });
/// ```
#[inline(always)]
fn as_bytes_mut(&mut self) -> &mut [u8]
fn as_mut_bytes(&mut self) -> &mut [u8]
where
Self: FromBytes + NoCell,
{
Expand Down Expand Up @@ -7749,7 +7749,7 @@ mod tests {
///
/// `bytes` is the expected byte sequence returned from `t.as_bytes()`
/// before `t` has been modified. `post_mutation` is the expected
/// sequence returned from `t.as_bytes()` after `t.as_bytes_mut()[0]`
/// sequence returned from `t.as_bytes()` after `t.as_mut_bytes()[0]`
/// has had its bits flipped (by applying `^= 0xFF`).
///
/// `N` is the size of `t` in bytes.
Expand All @@ -7764,9 +7764,9 @@ mod tests {

// Test that changes to the underlying byte slices are reflected in
// the original object.
t.as_bytes_mut()[0] ^= 0xFF;
t.as_mut_bytes()[0] ^= 0xFF;
assert_eq!(t, post_mutation);
t.as_bytes_mut()[0] ^= 0xFF;
t.as_mut_bytes()[0] ^= 0xFF;

// `write_to` rejects slices that are too small or too large.
assert_eq!(t.write_to(&mut vec![0; N - 1][..]), None);
Expand Down Expand Up @@ -8073,7 +8073,7 @@ mod tests {
//
// let r = <$ty as TryFromBytes>::try_from_ref(val.as_bytes()).unwrap();
// assert_eq!(r, &val);
// let r = <$ty as TryFromBytes>::try_from_mut(val.as_bytes_mut()).unwrap();
// let r = <$ty as TryFromBytes>::try_from_mut(val.as_mut_bytes()).unwrap();
// assert_eq!(r, &mut val);
// let v = <$ty as TryFromBytes>::try_read_from(val.as_bytes()).unwrap();
// assert_eq!(v, val);
Expand Down