Skip to content

Commit

Permalink
Remove --cfg uuid_unstable requirement for uuid_v7 feature (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
SanchithHegde authored Mar 10, 2024
1 parent c173c38 commit 89363c5
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 15 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/general.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ jobs:
test_uuid_v7:
name: Test
runs-on: ubuntu-latest
env:
RUSTFLAGS: "--cfg uuid_unstable"
RUSTDOCFLAGS: "--cfg uuid_unstable"
steps:
- uses: actions/checkout@v2
- name: Cache dependencies
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,6 @@ If you need to **trace** a request across multiple services (e.g. in a microserv

Optionally, using the `uuid_v7` feature flag will allow [`RequestId`] to use UUID v7 instead of the currently used UUID v4.

However, the [`uuid`] crate requires a compile time flag `uuid_unstable` to be passed in `RUSTFLAGS="--cfg uuid_unstable"` in order to compile. You can read more about it [here](https://docs.rs/uuid/latest/uuid/#unstable-features).

## Trace Id

To fulfill a request you often have to perform additional I/O operations - e.g. calls to other REST or gRPC APIs, database queries, etc.
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@
//!
//! Optionally, using the `uuid_v7` feature flag will allow [`RequestId`] to use UUID v7 instead of the currently used UUID v4.
//!
//! However, the [`uuid`] crate requires a compile time flag `uuid_unstable` to be passed in `RUSTFLAGS="--cfg uuid_unstable"` in order to compile. You can read more about it [here](https://docs.rs/uuid/latest/uuid/#unstable-features).
//!
//! ## Trace Id
//!
//! To fulfill a request you often have to perform additional I/O operations - e.g. calls to other REST or gRPC APIs, database queries, etc.
Expand Down
9 changes: 1 addition & 8 deletions src/request_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,16 @@ use uuid::Uuid;
/// ```
///
/// Optionally, using the `uuid_v7` feature flag will allow [`RequestId`] to use UUID v7 instead of the currently used UUID v4.
///
/// However, the [`uuid`] crate requires a compile time flag `uuid_unstable` to be passed in `RUSTFLAGS="--cfg uuid_unstable"` in order to compile. You can read more about it [here](https://docs.rs/uuid/latest/uuid/#unstable-features).
///
#[derive(Clone, Copy, Debug)]
pub struct RequestId(Uuid);

impl RequestId {
pub(crate) fn generate() -> Self {
// Compiler error for providing context on requirements to enable the `uuid_v7` feature flag
#[cfg(all(feature = "uuid_v7", not(uuid_unstable)))]
compile_error!("feature \"uuid_v7\" requires \"uuid_unstable\" to be passed as configuration in rustflags");

#[cfg(not(feature = "uuid_v7"))]
{
Self(Uuid::new_v4())
}
#[cfg(all(uuid_unstable, feature = "uuid_v7"))]
#[cfg(feature = "uuid_v7")]
{
Self(Uuid::now_v7())
}
Expand Down

0 comments on commit 89363c5

Please sign in to comment.