@@ -368,13 +368,6 @@ mod split_at;
368368// FIXME(#252): If we make this pub, come up with a better name.
369369mod wrappers;
370370
371- pub use crate :: byte_slice:: * ;
372- pub use crate :: byteorder:: * ;
373- pub use crate :: error:: * ;
374- pub use crate :: r#ref:: * ;
375- pub use crate :: split_at:: { Split , SplitAt } ;
376- pub use crate :: wrappers:: * ;
377-
378371use core:: {
379372 cell:: { Cell , UnsafeCell } ,
380373 cmp:: Ordering ,
@@ -390,28 +383,34 @@ use core::{
390383 ptr:: { self , NonNull } ,
391384 slice,
392385} ;
393-
394386#[ cfg( feature = "std" ) ]
395387use std:: io;
396388
397389use crate :: pointer:: invariant:: { self , BecauseExclusive } ;
390+ pub use crate :: {
391+ byte_slice:: * ,
392+ byteorder:: * ,
393+ error:: * ,
394+ r#ref:: * ,
395+ split_at:: { Split , SplitAt } ,
396+ wrappers:: * ,
397+ } ;
398398
399399#[ cfg( any( feature = "alloc" , test, kani) ) ]
400400extern crate alloc;
401401#[ cfg( any( feature = "alloc" , test) ) ]
402402use alloc:: { boxed:: Box , vec:: Vec } ;
403- use util:: MetadataOf ;
404-
405403#[ cfg( any( feature = "alloc" , test) ) ]
406404use core:: alloc:: Layout ;
407405
408- // Used by `TryFromBytes::is_bit_valid`.
409- #[ doc( hidden) ]
410- pub use crate :: pointer:: { invariant:: BecauseImmutable , Maybe , Ptr } ;
406+ use util:: MetadataOf ;
407+
411408// Used by `KnownLayout`.
412409#[ doc( hidden) ]
413410pub use crate :: layout:: * ;
414-
411+ // Used by `TryFromBytes::is_bit_valid`.
412+ #[ doc( hidden) ]
413+ pub use crate :: pointer:: { invariant:: BecauseImmutable , Maybe , Ptr } ;
415414// For each trait polyfill, as soon as the corresponding feature is stable, the
416415// polyfill import will be unused because method/function resolution will prefer
417416// the inherent method/function over a trait method/function. Thus, we suppress
@@ -448,9 +447,6 @@ const _: () = {
448447//
449448// The "note" provides enough context to make it easy to figure out how to fix
450449// the error.
451- #[ allow( unused) ]
452- use { FromZeros as FromZeroes , IntoBytes as AsBytes , Ref as LayoutVerified } ;
453-
454450/// Implements [`KnownLayout`].
455451///
456452/// This derive analyzes various aspects of a type's layout that are needed for
@@ -553,6 +549,8 @@ use {FromZeros as FromZeroes, IntoBytes as AsBytes, Ref as LayoutVerified};
553549#[ cfg( any( feature = "derive" , test) ) ]
554550#[ cfg_attr( doc_cfg, doc( cfg( feature = "derive" ) ) ) ]
555551pub use zerocopy_derive:: KnownLayout ;
552+ #[ allow( unused) ]
553+ use { FromZeros as FromZeroes , IntoBytes as AsBytes , Ref as LayoutVerified } ;
556554
557555/// Indicates that zerocopy can reason about certain aspects of a type's layout.
558556///
@@ -1165,7 +1163,6 @@ const _: () = unsafe {
11651163#[ cfg( any( feature = "derive" , test) ) ]
11661164#[ cfg_attr( doc_cfg, doc( cfg( feature = "derive" ) ) ) ]
11671165pub use zerocopy_derive:: FromZeros ;
1168-
11691166/// Analyzes whether a type is [`Immutable`].
11701167///
11711168/// This derive analyzes, at compile time, whether the annotated type satisfies
@@ -5550,22 +5547,22 @@ pub unsafe trait Unaligned {
55505547 Self : Sized ;
55515548}
55525549
5553- /// Derives an optimized [`Hash `] implementation .
5550+ /// Derives optimized [`PartialEq `] and [`Eq`] implementations .
55545551///
55555552/// This derive can be applied to structs and enums implementing both
55565553/// [`Immutable`] and [`IntoBytes`]; e.g.:
55575554///
55585555/// ```
5559- /// # use zerocopy_derive::{ByteHash , Immutable, IntoBytes};
5560- /// #[derive(ByteHash , Immutable, IntoBytes)]
5556+ /// # use zerocopy_derive::{ByteEq , Immutable, IntoBytes};
5557+ /// #[derive(ByteEq , Immutable, IntoBytes)]
55615558/// #[repr(C)]
55625559/// struct MyStruct {
55635560/// # /*
55645561/// ...
55655562/// # */
55665563/// }
55675564///
5568- /// #[derive(ByteHash , Immutable, IntoBytes)]
5565+ /// #[derive(ByteEq , Immutable, IntoBytes)]
55695566/// #[repr(u8)]
55705567/// enum MyEnum {
55715568/// # Variant,
@@ -5575,36 +5572,30 @@ pub unsafe trait Unaligned {
55755572/// }
55765573/// ```
55775574///
5578- /// The standard library's [`derive(Hash)`][derive@Hash] produces hashes by
5579- /// individually hashing each field and combining the results. Instead, the
5580- /// implementations of [`Hash::hash()`] and [`Hash::hash_slice()`] generated by
5581- /// `derive(ByteHash)` convert the entirety of `self` to a byte slice and hashes
5582- /// it in a single call to [`Hasher::write()`]. This may have performance
5583- /// advantages.
5584- ///
5585- /// [`Hash`]: core::hash::Hash
5586- /// [`Hash::hash()`]: core::hash::Hash::hash()
5587- /// [`Hash::hash_slice()`]: core::hash::Hash::hash_slice()
5575+ /// The standard library's [`derive(Eq, PartialEq)`][derive@PartialEq] computes
5576+ /// equality by individually comparing each field. Instead, the implementation
5577+ /// of [`PartialEq::eq`] emitted by `derive(ByteHash)` converts the entirety of
5578+ /// `self` and `other` to byte slices and compares those slices for equality.
5579+ /// This may have performance advantages.
55885580#[ cfg( any( feature = "derive" , test) ) ]
55895581#[ cfg_attr( doc_cfg, doc( cfg( feature = "derive" ) ) ) ]
5590- pub use zerocopy_derive:: ByteHash ;
5591-
5592- /// Derives optimized [`PartialEq`] and [`Eq`] implementations.
5582+ pub use zerocopy_derive:: ByteEq ;
5583+ /// Derives an optimized [`Hash`] implementation.
55935584///
55945585/// This derive can be applied to structs and enums implementing both
55955586/// [`Immutable`] and [`IntoBytes`]; e.g.:
55965587///
55975588/// ```
5598- /// # use zerocopy_derive::{ByteEq , Immutable, IntoBytes};
5599- /// #[derive(ByteEq , Immutable, IntoBytes)]
5589+ /// # use zerocopy_derive::{ByteHash , Immutable, IntoBytes};
5590+ /// #[derive(ByteHash , Immutable, IntoBytes)]
56005591/// #[repr(C)]
56015592/// struct MyStruct {
56025593/// # /*
56035594/// ...
56045595/// # */
56055596/// }
56065597///
5607- /// #[derive(ByteEq , Immutable, IntoBytes)]
5598+ /// #[derive(ByteHash , Immutable, IntoBytes)]
56085599/// #[repr(u8)]
56095600/// enum MyEnum {
56105601/// # Variant,
@@ -5614,15 +5605,19 @@ pub use zerocopy_derive::ByteHash;
56145605/// }
56155606/// ```
56165607///
5617- /// The standard library's [`derive(Eq, PartialEq)`][derive@PartialEq] computes
5618- /// equality by individually comparing each field. Instead, the implementation
5619- /// of [`PartialEq::eq`] emitted by `derive(ByteHash)` converts the entirety of
5620- /// `self` and `other` to byte slices and compares those slices for equality.
5621- /// This may have performance advantages.
5608+ /// The standard library's [`derive(Hash)`][derive@Hash] produces hashes by
5609+ /// individually hashing each field and combining the results. Instead, the
5610+ /// implementations of [`Hash::hash()`] and [`Hash::hash_slice()`] generated by
5611+ /// `derive(ByteHash)` convert the entirety of `self` to a byte slice and hashes
5612+ /// it in a single call to [`Hasher::write()`]. This may have performance
5613+ /// advantages.
5614+ ///
5615+ /// [`Hash`]: core::hash::Hash
5616+ /// [`Hash::hash()`]: core::hash::Hash::hash()
5617+ /// [`Hash::hash_slice()`]: core::hash::Hash::hash_slice()
56225618#[ cfg( any( feature = "derive" , test) ) ]
56235619#[ cfg_attr( doc_cfg, doc( cfg( feature = "derive" ) ) ) ]
5624- pub use zerocopy_derive:: ByteEq ;
5625-
5620+ pub use zerocopy_derive:: ByteHash ;
56265621/// Implements [`SplitAt`].
56275622///
56285623/// This derive can be applied to structs; e.g.:
0 commit comments