From bb2988aab724391751d66c6a022b5ed257e73242 Mon Sep 17 00:00:00 2001 From: Hunar Roop Kahlon Date: Mon, 19 Mar 2018 20:11:44 -0700 Subject: [PATCH 1/2] introduce the `uuid` prelude Signed-off-by: Hunar Roop Kahlon --- src/lib.rs | 4 +++- src/prelude.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 src/prelude.rs diff --git a/src/lib.rs b/src/lib.rs index f3a81c540..61e121602 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Generate and parse UUIDs +//! Generate and parse UUIDs. //! //! Provides support for Universally Unique Identifiers (UUIDs). A UUID is a //! unique 128-bit number, stored as 16 octets. UUIDs are used to assign @@ -168,6 +168,8 @@ cfg_if! { } } +pub mod prelude; + cfg_if! { if #[cfg(feature = "serde")] { mod serde_support; diff --git a/src/prelude.rs b/src/prelude.rs new file mode 100644 index 000000000..50266b752 --- /dev/null +++ b/src/prelude.rs @@ -0,0 +1,32 @@ +//! The [`uuid`] prelude. +//! +//! This module contains the most important items of the [`uuid`] crate. +//! +//! To use the prelude, include the following in your crate root: +//! +//! ```rust +//! extern crate uuid; +//! ``` +//! +//! and the following in every module: +//! +//! ```rust +//! use uuid::prelude::*; +//! ``` +//! +//! # Prelude Contents +//! +//! Currently the prelude reexports the following: +//! +//! ## The core types +//! +//! [`uuid`]`::{`[`ParseError`], [`Uuid`], [`UuidVariant`]`}`: The fundamental +//! types used in [`uuid`] crate. +//! +//! [`uuid`]: ../index.html +//! [`ParseError`]: ../enum.ParseError.html +//! [`Uuid`]: ../struct.Uuid.html +//! [`UuidVariant`]: enum.UuidVariant.html + +#[doc(inline)] +pub use super::{ParseError, Uuid, UuidVariant}; From 61a719a50a496472d0a6e8cbd25169d2a7939f34 Mon Sep 17 00:00:00 2001 From: Hunar Roop Kahlon Date: Thu, 22 Mar 2018 12:37:12 -0700 Subject: [PATCH 2/2] cargo fmt Signed-off-by: Hunar Roop Kahlon --- src/lib.rs | 51 ++++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 91c2c58e5..1d5542918 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1106,32 +1106,29 @@ impl<'a> fmt::Display for Hyphenated<'a> { } macro_rules! hyphenated_write { - ($f:expr, $format:expr, $bytes:expr) => {{ - - let data1 = u32::from($bytes[0]) << 24 | - u32::from($bytes[1]) << 16 | - u32::from($bytes[2]) << 8 | - u32::from($bytes[3]); - - let data2 = u16::from($bytes[4]) << 8 | - u16::from($bytes[5]); - - let data3 = u16::from($bytes[6]) << 8 | - u16::from($bytes[7]); - - write!($f, - $format, - data1, - data2, - data3, - $bytes[8], - $bytes[9], - $bytes[10], - $bytes[11], - $bytes[12], - $bytes[13], - $bytes[14], - $bytes[15]) + ($f: expr, $format: expr, $bytes: expr) => {{ + let data1 = u32::from($bytes[0]) << 24 | u32::from($bytes[1]) << 16 + | u32::from($bytes[2]) << 8 | u32::from($bytes[3]); + + let data2 = u16::from($bytes[4]) << 8 | u16::from($bytes[5]); + + let data3 = u16::from($bytes[6]) << 8 | u16::from($bytes[7]); + + write!( + $f, + $format, + data1, + data2, + data3, + $bytes[8], + $bytes[9], + $bytes[10], + $bytes[11], + $bytes[12], + $bytes[13], + $bytes[14], + $bytes[15] + ) }}; } @@ -1636,7 +1633,7 @@ mod tests { let u = new(); macro_rules! check { - ($buf:ident, $format:expr, $target:expr, $len:expr, $cond:expr) => { + ($buf: ident, $format: expr, $target: expr, $len: expr, $cond: expr) => { $buf.clear(); write!($buf, $format, $target).unwrap(); assert!(buf.len() == $len);