Skip to content

Commit 9787ea1

Browse files
authored
Merge pull request #718 from uuid-rs/feat/stabilize-v6-plus
Stabilize UUIDv6-v8 support
2 parents 90b0bc0 + 1eebe7d commit 9787ea1

File tree

8 files changed

+22
-38
lines changed

8 files changed

+22
-38
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ jobs:
8585
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
8686

8787
- name: Install Rust toolchain
88-
run: rustup update 1.57.0
88+
run: rustup update 1.60.0
8989

9090
- name: Version features
91-
run: cargo +1.57.0 build --manifest-path tests/smoke-test/Cargo.toml
91+
run: cargo +1.60.0 build --manifest-path tests/smoke-test/Cargo.toml
9292

9393
wasm_bindgen:
9494
name: Tests / WebAssembly (wasm-bindgen)
@@ -147,10 +147,10 @@ jobs:
147147
cargo +nightly miri setup
148148
149149
- name: Default features
150-
run: cargo +nightly miri test
150+
run: cargo +nightly miri test --lib
151151

152152
- name: BE
153-
run: cargo +nightly miri test --target s390x-unknown-linux-gnu
153+
run: cargo +nightly miri test --target s390x-unknown-linux-gnu --lib
154154

155155
clippy:
156156
name: Build / Clippy

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ name = "uuid"
2828
readme = "README.md"
2929
repository = "https://github.com/uuid-rs/uuid"
3030
version = "1.5.0" # remember to update html_root_url in lib.rs
31-
rust-version = "1.57.0"
31+
rust-version = "1.60.0"
3232

3333
[package.metadata.docs.rs]
3434
rustc-args = ["--cfg", "uuid_unstable"]

benches/v7.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![cfg(all(feature = "v7", feature = "std"))]
2+
#![feature(test)]
3+
extern crate test;
4+
5+
use test::Bencher;
6+
use uuid::Uuid;
7+
8+
#[bench]
9+
fn now_v7(b: &mut Bencher) {
10+
b.iter(|| Uuid::now_v7());
11+
}

examples/sortable_uuid.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! If you enable the `v7` feature you can generate sortable UUIDs.
44
5-
#[cfg(all(uuid_unstable, feature = "v7"))]
5+
#[cfg(feature = "v7")]
66
fn main() {
77
use uuid::Uuid;
88

@@ -13,5 +13,5 @@ fn main() {
1313
println!("{}", uuid);
1414
}
1515

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

src/builder.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ impl Uuid {
9595
/// uuid.hyphenated().to_string(),
9696
/// );
9797
/// ```
98-
#[cfg(uuid_unstable)]
9998
pub const fn max() -> Self {
10099
Uuid::from_bytes([0xFF; 16])
101100
}
@@ -600,7 +599,6 @@ impl Builder {
600599
/// Creates a `Builder` for a version 6 UUID using the supplied timestamp and node ID.
601600
///
602601
/// This method will encode the ticks, counter, and node ID in a sortable UUID.
603-
#[cfg(uuid_unstable)]
604602
pub const fn from_sorted_rfc4122_timestamp(
605603
ticks: u64,
606604
counter: u16,
@@ -638,7 +636,6 @@ impl Builder {
638636
/// # Ok(())
639637
/// # }
640638
/// ```
641-
#[cfg(uuid_unstable)]
642639
pub const fn from_unix_timestamp_millis(millis: u64, random_bytes: &[u8; 10]) -> Self {
643640
Builder(timestamp::encode_unix_timestamp_millis(
644641
millis,
@@ -650,7 +647,6 @@ impl Builder {
650647
///
651648
/// This method won't interpret the given bytes in any way, except to set the appropriate
652649
/// bits for the UUID version and variant.
653-
#[cfg(uuid_unstable)]
654650
pub const fn from_custom_bytes(custom_bytes: Bytes) -> Self {
655651
Builder::from_bytes(custom_bytes)
656652
.with_variant(Variant::RFC4122)

src/lib.rs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,11 @@ mod v3;
251251
mod v4;
252252
#[cfg(feature = "v5")]
253253
mod v5;
254-
#[cfg(all(uuid_unstable, feature = "v6"))]
254+
#[cfg(feature = "v6")]
255255
mod v6;
256-
#[cfg(all(uuid_unstable, feature = "v7"))]
256+
#[cfg(feature = "v7")]
257257
mod v7;
258-
#[cfg(all(uuid_unstable, feature = "v8"))]
258+
#[cfg(feature = "v8")]
259259
mod v8;
260260

261261
#[cfg(feature = "md5")]
@@ -312,16 +312,12 @@ pub enum Version {
312312
/// Version 5: SHA-1 hash.
313313
Sha1 = 5,
314314
/// Version 6: Sortable Timestamp and node ID.
315-
#[cfg(uuid_unstable)]
316315
SortMac = 6,
317316
/// Version 7: Timestamp and random.
318-
#[cfg(uuid_unstable)]
319317
SortRand = 7,
320318
/// Version 8: Custom.
321-
#[cfg(uuid_unstable)]
322319
Custom = 8,
323320
/// The "max" (all ones) UUID.
324-
#[cfg(uuid_unstable)]
325321
Max = 0xff,
326322
}
327323

@@ -575,13 +571,9 @@ impl Uuid {
575571
3 => Some(Version::Md5),
576572
4 => Some(Version::Random),
577573
5 => Some(Version::Sha1),
578-
#[cfg(uuid_unstable)]
579574
6 => Some(Version::SortMac),
580-
#[cfg(uuid_unstable)]
581575
7 => Some(Version::SortRand),
582-
#[cfg(uuid_unstable)]
583576
8 => Some(Version::Custom),
584-
#[cfg(uuid_unstable)]
585577
0xf => Some(Version::Max),
586578
_ => None,
587579
}
@@ -851,7 +843,6 @@ impl Uuid {
851843
}
852844

853845
/// Tests if the UUID is max (all ones).
854-
#[cfg(uuid_unstable)]
855846
pub const fn is_max(&self) -> bool {
856847
self.as_u128() == u128::MAX
857848
}
@@ -911,13 +902,11 @@ impl Uuid {
911902

912903
Some(Timestamp::from_rfc4122(ticks, counter))
913904
}
914-
#[cfg(uuid_unstable)]
915905
Some(Version::SortMac) => {
916906
let (ticks, counter) = timestamp::decode_sorted_rfc4122_timestamp(self);
917907

918908
Some(Timestamp::from_rfc4122(ticks, counter))
919909
}
920-
#[cfg(uuid_unstable)]
921910
Some(Version::SortRand) => {
922911
let millis = timestamp::decode_unix_timestamp_millis(self);
923912

@@ -1184,7 +1173,6 @@ mod tests {
11841173
}
11851174

11861175
#[test]
1187-
#[cfg(uuid_unstable)]
11881176
#[cfg_attr(
11891177
all(
11901178
target_arch = "wasm32",

src/macros.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,7 @@ macro_rules! define_uuid_macro {
1616
($uuid:literal) => {{
1717
const OUTPUT: $crate::Uuid = match $crate::Uuid::try_parse($uuid) {
1818
$crate::__macro_support::Ok(u) => u,
19-
$crate::__macro_support::Err(_) => {
20-
// here triggers const_err
21-
// const_panic requires 1.57
22-
#[allow(unconditional_panic)]
23-
let _ = ["invalid uuid representation"][1];
24-
25-
loop {} // -> never type
26-
}
19+
$crate::__macro_support::Err(e) => panic!("{}", e),
2720
};
2821
OUTPUT
2922
}};

src/timestamp.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ pub(crate) const fn decode_rfc4122_timestamp(uuid: &Uuid) -> (u64, u16) {
204204
(ticks, counter)
205205
}
206206

207-
#[cfg(uuid_unstable)]
208207
pub(crate) const fn encode_sorted_rfc4122_timestamp(
209208
ticks: u64,
210209
counter: u16,
@@ -228,7 +227,6 @@ pub(crate) const fn encode_sorted_rfc4122_timestamp(
228227
Uuid::from_fields(time_high, time_mid, time_low_and_version, &d4)
229228
}
230229

231-
#[cfg(uuid_unstable)]
232230
pub(crate) const fn decode_sorted_rfc4122_timestamp(uuid: &Uuid) -> (u64, u16) {
233231
let bytes = uuid.as_bytes();
234232

@@ -246,7 +244,6 @@ pub(crate) const fn decode_sorted_rfc4122_timestamp(uuid: &Uuid) -> (u64, u16) {
246244
(ticks, counter)
247245
}
248246

249-
#[cfg(uuid_unstable)]
250247
pub(crate) const fn encode_unix_timestamp_millis(millis: u64, random_bytes: &[u8; 10]) -> Uuid {
251248
let millis_high = ((millis >> 16) & 0xFFFF_FFFF) as u32;
252249
let millis_low = (millis & 0xFFFF) as u16;
@@ -268,7 +265,6 @@ pub(crate) const fn encode_unix_timestamp_millis(millis: u64, random_bytes: &[u8
268265
Uuid::from_fields(millis_high, millis_low, random_and_version, &d4)
269266
}
270267

271-
#[cfg(uuid_unstable)]
272268
pub(crate) const fn decode_unix_timestamp_millis(uuid: &Uuid) -> u64 {
273269
let bytes = uuid.as_bytes();
274270

0 commit comments

Comments
 (0)