From 33f6b3edd9ade424ce014dfc808576f657803fa3 Mon Sep 17 00:00:00 2001 From: KodrAus Date: Mon, 17 Jul 2023 08:38:54 +1000 Subject: [PATCH 1/2] print uuids in examples --- examples/random_uuid.rs | 6 ++++-- examples/sortable_uuid.rs | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/random_uuid.rs b/examples/random_uuid.rs index 897071c4..ec88c058 100644 --- a/examples/random_uuid.rs +++ b/examples/random_uuid.rs @@ -2,14 +2,16 @@ //! //! If you enable the `v4` feature you can generate random UUIDs. -#[test] #[cfg(feature = "v4")] -fn generate_random_uuid() { +fn main() { use uuid::Uuid; let uuid = Uuid::new_v4(); assert_eq!(Some(uuid::Version::Random), uuid.get_version()); + + println!("{}", uuid); } +#[cfg(not(feature = "v4"))] fn main() {} diff --git a/examples/sortable_uuid.rs b/examples/sortable_uuid.rs index dc128125..fd4b56f3 100644 --- a/examples/sortable_uuid.rs +++ b/examples/sortable_uuid.rs @@ -2,14 +2,16 @@ //! //! If you enable the `v7` feature you can generate sortable UUIDs. -#[test] #[cfg(feature = "v7")] -fn generate_sortable_uuid() { +fn main() { use uuid::Uuid; let uuid = Uuid::now_v7(); assert_eq!(Some(uuid::Version::SortRand), uuid.get_version()); + + println!("{}", uuid); } +#[cfg(not(feature = "v7"))] fn main() {} From 5a1f3f56d34365a7c85a36585225bc3f20a9b6f3 Mon Sep 17 00:00:00 2001 From: KodrAus Date: Mon, 17 Jul 2023 08:45:31 +1000 Subject: [PATCH 2/2] use uuid_unstable --- examples/sortable_uuid.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/sortable_uuid.rs b/examples/sortable_uuid.rs index fd4b56f3..0f8c21da 100644 --- a/examples/sortable_uuid.rs +++ b/examples/sortable_uuid.rs @@ -2,7 +2,7 @@ //! //! If you enable the `v7` feature you can generate sortable UUIDs. -#[cfg(feature = "v7")] +#[cfg(all(uuid_unstable, feature = "v7"))] fn main() { use uuid::Uuid; @@ -13,5 +13,5 @@ fn main() { println!("{}", uuid); } -#[cfg(not(feature = "v7"))] +#[cfg(not(all(uuid_unstable, feature = "v7")))] fn main() {}