Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename NoCell to Immutable #1137

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ functionality themselves, but are required to call certain methods provided
by the conversion traits:
- `KnownLayout` indicates that zerocopy can reason about certain layout
qualities of a type
- `NoCell` indicates that a type does not contain any `UnsafeCell`s
- `Immutable` indicates that a type does not contain any `UnsafeCell`s
- `Unaligned` indicates that a type's alignment requirement is 1

You should generally derive these marker traits whenever possible.
Expand Down
14 changes: 7 additions & 7 deletions src/byteorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
//!
//! ```rust,edition2021
//! # #[cfg(feature = "derive")] { // This example uses derives, and won't compile without them
//! use zerocopy::{IntoBytes, FromBytes, KnownLayout, NoCell, Ref, SplitByteSlice, Unaligned};
//! use zerocopy::{IntoBytes, FromBytes, KnownLayout, Immutable, Ref, SplitByteSlice, Unaligned};
//! use zerocopy::byteorder::network_endian::U16;
//!
//! #[derive(FromBytes, IntoBytes, KnownLayout, NoCell, Unaligned)]
//! #[derive(FromBytes, IntoBytes, KnownLayout, Immutable, Unaligned)]
//! #[repr(C)]
//! struct UdpHeader {
//! src_port: U16,
Expand Down Expand Up @@ -378,7 +378,7 @@ example of how it can be used for parsing UDP packets.
[`IntoBytes`]: crate::IntoBytes
[`Unaligned`]: crate::Unaligned"),
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
#[cfg_attr(any(feature = "derive", test), derive(KnownLayout, NoCell, FromBytes, IntoBytes, Unaligned))]
#[cfg_attr(any(feature = "derive", test), derive(KnownLayout, Immutable, FromBytes, IntoBytes, Unaligned))]
#[repr(transparent)]
pub struct $name<O>([u8; $bytes], PhantomData<O>);
}
Expand All @@ -390,9 +390,9 @@ example of how it can be used for parsing UDP packets.
/// SAFETY:
/// `$name<O>` is `repr(transparent)`, and so it has the same layout
/// as its only non-zero field, which is a `u8` array. `u8` arrays
/// are `NoCell`, `TryFromBytes`, `FromZeros`, `FromBytes`,
/// are `Immutable`, `TryFromBytes`, `FromZeros`, `FromBytes`,
/// `IntoBytes`, and `Unaligned`.
impl_or_verify!(O => NoCell for $name<O>);
impl_or_verify!(O => Immutable for $name<O>);
impl_or_verify!(O => TryFromBytes for $name<O>);
impl_or_verify!(O => FromZeros for $name<O>);
impl_or_verify!(O => FromBytes for $name<O>);
Expand Down Expand Up @@ -903,7 +903,7 @@ mod tests {
use compatibility::*;

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

Expand Down Expand Up @@ -948,7 +948,7 @@ mod tests {
}

trait ByteArray:
FromBytes + IntoBytes + NoCell + Copy + AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Eq
FromBytes + IntoBytes + Immutable + Copy + AsRef<[u8]> + AsMut<[u8]> + Debug + Default + Eq
{
/// Invert the order of the bytes in the array.
fn invert(self) -> Self;
Expand Down
8 changes: 4 additions & 4 deletions src/deprecated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use super::*;
impl<B, T> Ref<B, [T]>
where
B: ByteSlice,
T: NoCell,
T: Immutable,
{
#[deprecated(since = "0.8.0", note = "`Ref::new` now supports slices")]
#[doc(hidden)]
Expand All @@ -28,7 +28,7 @@ where
impl<B, T> Ref<B, [T]>
where
B: ByteSlice,
T: Unaligned + NoCell,
T: Unaligned + Immutable,
{
#[deprecated(since = "0.8.0", note = "`Ref::new_unaligned` now supports slices")]
#[doc(hidden)]
Expand All @@ -41,7 +41,7 @@ where
impl<'a, B, T> Ref<B, [T]>
where
B: 'a + IntoByteSlice<'a>,
T: FromBytes + NoCell,
T: FromBytes + Immutable,
{
#[deprecated(since = "0.8.0", note = "`Ref::into_ref` now supports slices")]
#[doc(hidden)]
Expand All @@ -54,7 +54,7 @@ where
impl<'a, B, T> Ref<B, [T]>
where
B: 'a + IntoByteSliceMut<'a>,
T: FromBytes + IntoBytes + NoCell,
T: FromBytes + IntoBytes + Immutable,
{
#[deprecated(since = "0.8.0", note = "`Ref::into_mut` now supports slices")]
#[doc(hidden)]
Expand Down