Skip to content

Commit

Permalink
Fix flaky TryFromBytes tests (#1998)
Browse files Browse the repository at this point in the history
These tests depend on `src` being aligned to multiples of 2. With
this commit, that dependency is explicitly enforced.
  • Loading branch information
jswrenn authored Oct 31, 2024
1 parent 0becfe8 commit 192387c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &[85, 85][..];
/// let src = 0xCAFEu16.as_bytes();
/// let zsty = ZSTy::try_ref_from_bytes_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down Expand Up @@ -2090,7 +2090,7 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &[85, 85][..];
/// let src = 0xCAFEu16.as_bytes();
/// let (zsty, _) = ZSTy::try_ref_from_prefix_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down Expand Up @@ -2179,7 +2179,7 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &[85, 85][..];
/// let src = 0xCAFEu16.as_bytes();
/// let (_, zsty) = ZSTy::try_ref_from_suffix_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down Expand Up @@ -2269,7 +2269,8 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &mut [85, 85][..];
/// let mut src = 0xCAFEu16;
/// let src = src.as_mut_bytes();
/// let zsty = ZSTy::try_mut_from_bytes_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down Expand Up @@ -2381,7 +2382,8 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &mut [85, 85][..];
/// let mut src = 0xCAFEu16;
/// let src = src.as_mut_bytes();
/// let (zsty, _) = ZSTy::try_mut_from_prefix_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down Expand Up @@ -2475,7 +2477,8 @@ pub unsafe trait TryFromBytes {
/// trailing_dst: [()],
/// }
///
/// let src = &mut [85, 85][..];
/// let mut src = 0xCAFEu16;
/// let src = src.as_mut_bytes();
/// let (_, zsty) = ZSTy::try_mut_from_suffix_with_elems(src, 42).unwrap();
/// assert_eq!(zsty.trailing_dst.len(), 42);
/// ```
Expand Down

0 comments on commit 192387c

Please sign in to comment.