Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
rustflags = ["--cfg=uuid_unstable"]
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ rust-version = "1.67.1"

[features]
default = ["fast-rng"]
arbitrary = ["uuid/arbitrary", "arbitrary/derive"] # Add support for arbitrary types
random = ["uuid/v4"] # Create random ShortGuid IDs
fast-rng = ["random", "uuid/fast-rng"] # Use a faster (but still sufficiently random) RNG
serde = ["dep:serde", "uuid/serde"] # Serialization and deserialization support
# zerocopy = ["dep:zerocopy", "uuid/zerocopy"] # Zerocopy support
bytemuck = ["dep:bytemuck", "uuid/bytemuck"] # Bytemuck support
arbitrary = ["uuid/arbitrary", "arbitrary/derive"] # Add support for arbitrary types
random = ["uuid/v4"] # Create random ShortGuid IDs
fast-rng = ["random", "uuid/fast-rng"] # Use a faster (but still sufficiently random) RNG
serde = ["dep:serde", "uuid/serde"] # Serialization and deserialization support
zerocopy = ["dep:zerocopy", "uuid/zerocopy"] # Zerocopy support
bytemuck = ["dep:bytemuck", "uuid/bytemuck"] # Bytemuck support
borsh = ["dep:borsh", "dep:borsh-derive", "uuid/borsh"] # Borsh support

[[example]]
Expand All @@ -42,7 +42,7 @@ zerocopy = { version = "0.7.33", optional = true, features = ["derive"] }

[dev-dependencies]
hex = "0.4.3"
clap = "4.5.4"
clap = "4.4.11"
serde_test = "1.0.176"

[package.metadata.docs.rs]
Expand Down
11 changes: 7 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ use std::fmt::{Debug, Display, Formatter};
use std::str::FromStr;
use uuid::Uuid;

#[cfg(all(uuid_unstable, feature = "zerocopy"))]
use zerocopy::{AsBytes, FromBytes, Unaligned};

/// A short, URL-safe UUID representation.
///
/// ## Example
Expand All @@ -67,10 +70,10 @@ use uuid::Uuid;
/// ```
#[derive(Default, Copy, Clone, Eq, PartialEq, Hash, Ord, PartialOrd)]
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
// #[cfg_attr(
// feature = "zerocopy",
// derive(zerocopy::AsBytes, zerocopy::FromBytes, zerocopy::Unaligned)
// )]
#[cfg_attr(
all(uuid_unstable, feature = "zerocopy"),
derive(AsBytes, FromBytes, Unaligned)
)]
#[cfg_attr(
feature = "borsh",
derive(borsh_derive::BorshDeserialize, borsh_derive::BorshSerialize)
Expand Down