Skip to content

Commit 243c452

Browse files
authored
Rename NoCell to Immutable (#1137)
We selected `Immutable` on @rcoh's suggestion that our name for this be a single, evocative word, like `Send` and `Sync`. As with `Send` and `Sync`, we do not hope that `Immutable`, on its own, captures the entire semantics of this trait; the burden of entirely capturing its semantics rests on its documentation. We are not overly concerned with the risk of future conflict with Rust. If and when Rust stabilizes its own version of this trait, we will adjust zerocopy to use Rust's trait instead. Closes #994
1 parent 22c08d4 commit 243c452

Some content is hidden

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

60 files changed

+744
-730
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ functionality themselves, but are required to call certain methods provided
4444
by the conversion traits:
4545
- `KnownLayout` indicates that zerocopy can reason about certain layout
4646
qualities of a type
47-
- `NoCell` indicates that a type does not contain any `UnsafeCell`s
47+
- `Immutable` indicates that a type does not contain any `UnsafeCell`s
4848
- `Unaligned` indicates that a type's alignment requirement is 1
4949

5050
You should generally derive these marker traits whenever possible.

src/byteorder.rs

Lines changed: 7 additions & 7 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::{IntoBytes, FromBytes, KnownLayout, NoCell, Ref, SplitByteSlice, Unaligned};
38+
//! use zerocopy::{IntoBytes, FromBytes, KnownLayout, Immutable, Ref, SplitByteSlice, Unaligned};
3939
//! use zerocopy::byteorder::network_endian::U16;
4040
//!
41-
//! #[derive(FromBytes, IntoBytes, KnownLayout, NoCell, Unaligned)]
41+
//! #[derive(FromBytes, IntoBytes, KnownLayout, Immutable, Unaligned)]
4242
//! #[repr(C)]
4343
//! struct UdpHeader {
4444
//! src_port: U16,
@@ -378,7 +378,7 @@ example of how it can be used for parsing UDP packets.
378378
[`IntoBytes`]: crate::IntoBytes
379379
[`Unaligned`]: crate::Unaligned"),
380380
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
381-
#[cfg_attr(any(feature = "derive", test), derive(KnownLayout, NoCell, FromBytes, IntoBytes, Unaligned))]
381+
#[cfg_attr(any(feature = "derive", test), derive(KnownLayout, Immutable, FromBytes, IntoBytes, Unaligned))]
382382
#[repr(transparent)]
383383
pub struct $name<O>([u8; $bytes], PhantomData<O>);
384384
}
@@ -390,9 +390,9 @@ example of how it can be used for parsing UDP packets.
390390
/// SAFETY:
391391
/// `$name<O>` is `repr(transparent)`, and so it has the same layout
392392
/// as its only non-zero field, which is a `u8` array. `u8` arrays
393-
/// are `NoCell`, `TryFromBytes`, `FromZeros`, `FromBytes`,
393+
/// are `Immutable`, `TryFromBytes`, `FromZeros`, `FromBytes`,
394394
/// `IntoBytes`, and `Unaligned`.
395-
impl_or_verify!(O => NoCell for $name<O>);
395+
impl_or_verify!(O => Immutable for $name<O>);
396396
impl_or_verify!(O => TryFromBytes for $name<O>);
397397
impl_or_verify!(O => FromZeros for $name<O>);
398398
impl_or_verify!(O => FromBytes for $name<O>);
@@ -903,7 +903,7 @@ mod tests {
903903
use compatibility::*;
904904

905905
// A native integer type (u16, i32, etc).
906-
trait Native: Arbitrary + FromBytes + IntoBytes + NoCell + Copy + PartialEq + Debug {
906+
trait Native: Arbitrary + FromBytes + IntoBytes + Immutable + Copy + PartialEq + Debug {
907907
const ZERO: Self;
908908
const MAX_VALUE: Self;
909909

@@ -948,7 +948,7 @@ mod tests {
948948
}
949949

950950
trait ByteArray:
951-
FromBytes + IntoBytes + NoCell + Copy + AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Eq
951+
FromBytes + IntoBytes + Immutable + Copy + AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Eq
952952
{
953953
/// Invert the order of the bytes in the array.
954954
fn invert(self) -> Self;

src/deprecated.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use super::*;
1515
impl<B, T> Ref<B, [T]>
1616
where
1717
B: ByteSlice,
18-
T: NoCell,
18+
T: Immutable,
1919
{
2020
#[deprecated(since = "0.8.0", note = "`Ref::new` now supports slices")]
2121
#[doc(hidden)]
@@ -28,7 +28,7 @@ where
2828
impl<B, T> Ref<B, [T]>
2929
where
3030
B: ByteSlice,
31-
T: Unaligned + NoCell,
31+
T: Unaligned + Immutable,
3232
{
3333
#[deprecated(since = "0.8.0", note = "`Ref::new_unaligned` now supports slices")]
3434
#[doc(hidden)]
@@ -41,7 +41,7 @@ where
4141
impl<'a, B, T> Ref<B, [T]>
4242
where
4343
B: 'a + IntoByteSlice<'a>,
44-
T: FromBytes + NoCell,
44+
T: FromBytes + Immutable,
4545
{
4646
#[deprecated(since = "0.8.0", note = "`Ref::into_ref` now supports slices")]
4747
#[doc(hidden)]
@@ -54,7 +54,7 @@ where
5454
impl<'a, B, T> Ref<B, [T]>
5555
where
5656
B: 'a + IntoByteSliceMut<'a>,
57-
T: FromBytes + IntoBytes + NoCell,
57+
T: FromBytes + IntoBytes + Immutable,
5858
{
5959
#[deprecated(since = "0.8.0", note = "`Ref::into_mut` now supports slices")]
6060
#[doc(hidden)]

0 commit comments

Comments
 (0)