Skip to content

Commit

Permalink
Merge pull request #697 from uuid-rs/chore/example-printing
Browse files Browse the repository at this point in the history
Print uuids in examples
  • Loading branch information
KodrAus committed Jul 17, 2023
2 parents 6b0cfb2 + 5a1f3f5 commit 0041b3b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions examples/random_uuid.rs
Expand Up @@ -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() {}
8 changes: 5 additions & 3 deletions examples/sortable_uuid.rs
Expand Up @@ -2,14 +2,16 @@
//!
//! If you enable the `v7` feature you can generate sortable UUIDs.

#[test]
#[cfg(feature = "v7")]
fn generate_sortable_uuid() {
#[cfg(all(uuid_unstable, feature = "v7"))]
fn main() {
use uuid::Uuid;

let uuid = Uuid::now_v7();

assert_eq!(Some(uuid::Version::SortRand), uuid.get_version());

println!("{}", uuid);
}

#[cfg(not(all(uuid_unstable, feature = "v7")))]
fn main() {}

0 comments on commit 0041b3b

Please sign in to comment.