Skip to content

Commit

Permalink
Rename LayoutVerified to Ref
Browse files Browse the repository at this point in the history
While `LayoutVerified` is technically a descriptive name, it doesn't
give much of a hint as to what the type's intended use is. The way it is
used in practice is as a sort of "smart" reference - the only difference
from a native reference (`&` or `&mut`) is that it is generic over the
mutability of the byte slice from which it was constructed. Thus, `Ref`
is a more helpful and informative name.

Closes #68
  • Loading branch information
joshlf committed Jul 29, 2023
1 parent b5b30d0 commit afddc03
Show file tree
Hide file tree
Showing 2 changed files with 424 additions and 516 deletions.
6 changes: 3 additions & 3 deletions src/byteorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
//! UDP:
//!
//! ```edition2021
//! use zerocopy::{AsBytes, ByteSlice, FromBytes, FromZeroes, LayoutVerified, Unaligned};
//! use zerocopy::{AsBytes, ByteSlice, FromBytes, FromZeroes, Ref, Unaligned};
//! use zerocopy::byteorder::network_endian::U16;
//!
//! #[derive(FromZeroes, FromBytes, AsBytes, Unaligned)]
Expand All @@ -43,13 +43,13 @@
//! }
//!
//! struct UdpPacket<B: ByteSlice> {
//! header: LayoutVerified<B, UdpHeader>,
//! header: Ref<B, UdpHeader>,
//! body: B,
//! }
//!
//! impl<B: ByteSlice> UdpPacket<B> {
//! fn parse(bytes: B) -> Option<UdpPacket<B>> {
//! let (header, body) = LayoutVerified::new_from_prefix(bytes)?;
//! let (header, body) = Ref::new_from_prefix(bytes)?;
//! Some(UdpPacket { header, body })
//! }
//!
Expand Down
Loading

0 comments on commit afddc03

Please sign in to comment.