Skip to content

Commit dd73d95

Browse files
committed
Traits other than NoCell permit UnsafeCells
TODO: - `transmute_ref!` and `transmute_mut!` enforce `Sized` bound separately from other traits so that error messages aren't duplicated - Tests - Exercise transmuting `UnsafeCell`s by value - UI tests for `transmute_ref!` and `transmute_mut!` for types which don't implement `NoCell` - Time to rename `AsBytes` to `ToBytes`? Closes #251
1 parent 62ee07e commit dd73d95

File tree

82 files changed

+1152
-673
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1152
-673
lines changed

src/byteorder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
//!
3636
//! ```rust,edition2021
3737
//! # #[cfg(feature = "derive")] { // This example uses derives, and won't compile without them
38-
//! use zerocopy::{AsBytes, ByteSlice, FromBytes, FromZeros, Ref, Unaligned};
38+
//! use zerocopy::{AsBytes, ByteSlice, FromBytes, FromZeros, NoCell, Ref, Unaligned};
3939
//! use zerocopy::byteorder::network_endian::U16;
4040
//!
41-
//! #[derive(FromZeros, FromBytes, AsBytes, Unaligned)]
41+
//! #[derive(FromZeros, FromBytes, AsBytes, NoCell, Unaligned)]
4242
//! #[repr(C)]
4343
//! struct UdpHeader {
4444
//! src_port: U16,
@@ -655,7 +655,7 @@ mod tests {
655655
use compatibility::*;
656656

657657
// A native integer type (u16, i32, etc).
658-
trait Native: Arbitrary + FromBytes + AsBytes + Copy + PartialEq + Debug {
658+
trait Native: Arbitrary + FromBytes + AsBytes + NoCell + Copy + PartialEq + Debug {
659659
const ZERO: Self;
660660
const MAX_VALUE: Self;
661661

@@ -692,7 +692,7 @@ mod tests {
692692
}
693693

694694
trait ByteArray:
695-
FromBytes + AsBytes + Copy + AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Eq
695+
FromBytes + AsBytes + NoCell + Copy + AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Eq
696696
{
697697
/// Invert the order of the bytes in the array.
698698
fn invert(self) -> Self;

0 commit comments

Comments
 (0)