Skip to content

Commit

Permalink
Merge #399
Browse files Browse the repository at this point in the history
399: remove Uuid::from_random_bytes r=Dylan-DPC a=kinggoesgaming

**I'm submitting a(n)** removal

# Description
Removed `Uuid::from_random_bytes(crate::Bytes) -> Self`

# Motivation
`Uuid::from_random_bytes` was already deprecated. Time to remove.

# Tests
All tests should pass. A test regarding the `Uuid::from_random_bytes` was removed.

# Related Issue(s)
N/A

Co-authored-by: Hunar Roop Kahlon <[email protected]>
  • Loading branch information
bors[bot] and kinggoesgaming committed Apr 21, 2019
2 parents 75f70a5 + 5d6b5e6 commit 7751923
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,38 +527,6 @@ impl Uuid {
Uuid(bytes)
}

/// Creates a v4 Uuid from random bytes (e.g. bytes supplied from `Rand`
/// crate)
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// use uuid::Bytes;
/// use uuid::Uuid;
///
/// let bytes: Bytes = [
/// 70, 235, 208, 238, 14, 109, 67, 201, 185, 13, 204, 195, 90, 145, 63, 62,
/// ];
/// let uuid = Uuid::from_random_bytes(bytes);
/// let uuid = uuid.to_hyphenated().to_string();
///
/// let expected_uuid = String::from("46ebd0ee-0e6d-43c9-b90d-ccc35a913f3e");
///
/// assert_eq!(expected_uuid, uuid);
/// ```
#[deprecated(
since = "0.7.2",
note = "please use the `uuid::Builder` instead to set the variant and version"
)]
pub fn from_random_bytes(bytes: Bytes) -> Uuid {
let mut uuid = Uuid::from_bytes(bytes);
uuid.set_variant(Variant::RFC4122);
uuid.set_version(Version::Random);
uuid
}

/// Specifies the variant of the UUID structure
fn set_variant(&mut self, v: Variant) {
// Octet 8 contains the variant in the most significant 3 bits
Expand Down Expand Up @@ -1461,20 +1429,6 @@ mod tests {
assert_eq!(&b_in, b_out);
}

#[test]
#[allow(deprecated)]
fn test_from_random_bytes() {
let b = [
0xa1, 0xa2, 0xa3, 0xa4, 0xb1, 0xb2, 0xc1, 0xc2, 0xd1, 0xd2, 0xd3,
0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
];

let u = Uuid::from_random_bytes(b);
let expected = "a1a2a3a4b1b241c291d2d3d4d5d6d7d8";

assert_eq!(u.to_simple().to_string(), expected);
}

#[test]
fn test_iterbytes_impl_for_uuid() {
let mut set = std::collections::HashSet::new();
Expand Down

0 comments on commit 7751923

Please sign in to comment.