From bff9148ad8e7bf034e0992a1f8b4bf9553f2e386 Mon Sep 17 00:00:00 2001 From: Ryan <73195765+dorryspears@users.noreply.github.com> Date: Mon, 12 Feb 2024 18:02:38 -0500 Subject: [PATCH] Rename `as_bytes_mut` to `as_mut_bytes` Fixes #253 --- src/byteorder.rs | 2 +- src/lib.rs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/byteorder.rs b/src/byteorder.rs index 03dfe028af..f0b95dc2a6 100644 --- a/src/byteorder.rs +++ b/src/byteorder.rs @@ -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(); } diff --git a/src/lib.rs b/src/lib.rs index 0860be9c4e..adb6fb4a8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 @@ -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]); /// @@ -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, { @@ -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. @@ -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); @@ -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);