From 2799026a3b93c766d9a79016f75e01a17eb23a88 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Thu, 17 Oct 2019 14:52:35 +1000 Subject: [PATCH 1/2] prepare for 0.8.0 release --- Cargo.toml | 2 +- README.md | 8 ++++---- src/lib.rs | 37 +++++++++++++++++++++++++++++++++++-- src/parser/error.rs | 18 ------------------ 4 files changed, 40 insertions(+), 25 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f6b54ec33..9775f64b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ homepage = "https://github.com/uuid-rs/uuid" name = "uuid" readme = "README.md" repository = "https://github.com/uuid-rs/uuid" -version = "0.7.4" # remember to update html_root_url in lib.rs +version = "0.8.0" # remember to update html_root_url in lib.rs [package.metadata.docs.rs] features = [ "guid", "serde", "slog", "v1", "v3", "v4", "v5" ] diff --git a/README.md b/README.md index 9d3733387..b0e176211 100644 --- a/README.md +++ b/README.md @@ -57,21 +57,21 @@ By default, `uuid` can be depended on with: ```toml [dependencies] -uuid = "0.7" +uuid = "0.8.0" ``` To activate various features, use syntax like: ```toml [dependencies] -uuid = { version = "0.7", features = ["serde", "v4"] } +uuid = { version = "0.8.0", features = ["serde", "v4"] } ``` You can disable default features with: ```toml [dependencies] -uuid = { version = "0.7", default-features = false } +uuid = { version = "0.8.0", default-features = false } ``` ## Examples @@ -116,7 +116,7 @@ Examples of string representations: [`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen -[`Uuid`]: https://docs.rs/uuid/0.7.4/uuid/struct.Uuid.html +[`Uuid`]: https://docs.rs/uuid/0.8.0/uuid/struct.Uuid.html --- # License diff --git a/src/lib.rs b/src/lib.rs index 0303f99bd..76945ff49 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,7 +119,7 @@ #![doc( html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", html_favicon_url = "https://www.rust-lang.org/favicon.ico", - html_root_url = "https://docs.rs/uuid/0.7.4" + html_root_url = "https://docs.rs/uuid/0.8.0" )] #[cfg(any(feature = "std", test))] @@ -398,7 +398,22 @@ impl Uuid { (d1, d2, d3, d4) } - /// Returns a 128bit big-endian value containing the UUID data. + /// Returns a 128bit value containing the UUID data. + /// + /// The bytes in the UUID will be packed into a `u128`, like the `as_bytes` + /// method. + /// + /// # Examples + /// + /// ``` + /// use uuid::Uuid; + /// + /// let uuid = Uuid::parse_str("936DA01F-9ABD-4D9D-80C7-02AF85C822A8").unwrap(); + /// assert_eq!( + /// uuid.as_u128(), + /// 0x936DA01F9ABD4D9D80C702AF85C822A8, + /// ) + /// ``` pub fn as_u128(&self) -> u128 { u128::from(self.as_bytes()[0]) << 120 | u128::from(self.as_bytes()[1]) << 112 @@ -419,6 +434,24 @@ impl Uuid { } /// Returns a 128bit little-endian value containing the UUID data. + /// + /// The bytes in the UUID will be reversed and packed into a `u128`. + /// Note that this will produce a different result than `to_fields_le`, + /// because the entire UUID is reversed, rather than reversing the + /// individual fields in-place. + /// + /// # Examples + /// + /// ``` + /// use uuid::Uuid; + /// + /// let uuid = Uuid::parse_str("936DA01F-9ABD-4D9D-80C7-02AF85C822A8").unwrap(); + /// + /// assert_eq!( + /// uuid.to_u128_le(), + /// 0xA822C885AF02C7809D4DBD9A1FA06D93, + /// ) + /// ``` pub fn to_u128_le(&self) -> u128 { u128::from(self.as_bytes()[0]) | u128::from(self.as_bytes()[1]) << 8 diff --git a/src/parser/error.rs b/src/parser/error.rs index 706025190..39d502f3b 100644 --- a/src/parser/error.rs +++ b/src/parser/error.rs @@ -66,24 +66,13 @@ pub(crate) enum ExpectedLength { Any(&'static [usize]), /// Expected the given value. Exact(usize), - /// Expected any values in the given range. - Range { - /// The minimum expected value. - min: usize, - /// The maximum expected value. - max: usize, - }, } /// Urn prefix value. #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub(crate) enum UrnPrefix { - /// No `urn:uuid:` prefix should be provided. - None, /// The `urn:uuid:` prefix should optionally provided. Optional, - /// The `urn:uuid:` prefix is required. - Required, } impl Error { @@ -102,9 +91,6 @@ impl fmt::Display for ExpectedLength { match *self { ExpectedLength::Any(crits) => write!(f, "one of {:?}", crits), ExpectedLength::Exact(crit) => write!(f, "{}", crit), - ExpectedLength::Range { min, max } => { - write!(f, "{}..{} inclusive", min, max) - } } } } @@ -121,13 +107,9 @@ impl fmt::Display for Error { urn, } => { let urn_str = match urn { - UrnPrefix::None => "", UrnPrefix::Optional => { " an optional prefix of `urn:uuid:` followed by" } - UrnPrefix::Required => { - " a prefix of `urn:uuid` followed by" - } }; write!( From b03c09891d1db1bcce34bac793f955997f487f58 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Thu, 17 Oct 2019 21:54:24 +1000 Subject: [PATCH 2/2] use simpler version bound in readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b0e176211..71f8ae824 100644 --- a/README.md +++ b/README.md @@ -57,21 +57,21 @@ By default, `uuid` can be depended on with: ```toml [dependencies] -uuid = "0.8.0" +uuid = "0.8" ``` To activate various features, use syntax like: ```toml [dependencies] -uuid = { version = "0.8.0", features = ["serde", "v4"] } +uuid = { version = "0.8", features = ["serde", "v4"] } ``` You can disable default features with: ```toml [dependencies] -uuid = { version = "0.8.0", default-features = false } +uuid = { version = "0.8", default-features = false } ``` ## Examples