Skip to content

Commit

Permalink
add a few missing derives
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Jan 14, 2025
1 parent 402a8be commit 4ffd872
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/external/arbitrary_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl Arbitrary<'_> for Uuid {
impl arbitrary::Arbitrary<'_> for NonNilUuid {
fn arbitrary(u: &mut arbitrary::Unstructured<'_>) -> arbitrary::Result<Self> {
let uuid = Uuid::arbitrary(u)?;
Self::try_from(uuid).map_err(|_| arbitrary::Error::NotEnoughData)
Self::try_from(uuid).map_err(|_| arbitrary::Error::IncorrectFormat)
}

fn size_hint(_: usize) -> (usize, Option<usize>) {
Expand Down
2 changes: 1 addition & 1 deletion src/external/serde_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'de> Deserialize<'de> for NonNilUuid {
{
let uuid = Uuid::deserialize(deserializer)?;

NonNilUuid::try_from(uuid).map_err(|_| de::Error::custom("Uuid cannot be nil"))
NonNilUuid::try_from(uuid).map_err(|_| de::Error::invalid_value(de::Unexpected::Other("nil UUID"), &"a non-nil UUID"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ pub enum Variant {
///
/// The `Uuid` type is always guaranteed to be have the same ABI as [`Bytes`].
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(transparent)]
#[cfg_attr(
all(uuid_unstable, feature = "zerocopy"),
derive(IntoBytes, FromBytes, KnownLayout, Immutable, Unaligned)
Expand All @@ -445,7 +446,6 @@ pub enum Variant {
feature = "borsh",
derive(borsh_derive::BorshDeserialize, borsh_derive::BorshSerialize)
)]
#[repr(transparent)]
#[cfg_attr(
feature = "bytemuck",
derive(bytemuck::Zeroable, bytemuck::Pod, bytemuck::TransparentWrapper)
Expand Down
9 changes: 9 additions & 0 deletions src/non_nil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ use crate::{
/// - [`Uuid::new_v7`]
/// - [`Uuid::now_v7`]
/// - [`Uuid::new_v8`]
#[cfg_attr(
all(uuid_unstable, feature = "zerocopy"),
derive(IntoBytes, FromBytes, KnownLayout, Immutable, Unaligned)
)]
#[cfg_attr(
feature = "borsh",
derive(borsh_derive::BorshDeserialize, borsh_derive::BorshSerialize)
)]
#[repr(transparent)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct NonNilUuid(NonZeroU128);

Expand Down

0 comments on commit 4ffd872

Please sign in to comment.