Skip to content

Commit

Permalink
Rename as_bytes_mut to as_mut_bytes Fixes #253
Browse files Browse the repository at this point in the history
  • Loading branch information
dorryspears committed Feb 13, 2024
1 parent 4293509 commit bff9148
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
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

0 comments on commit bff9148

Please sign in to comment.