Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove Uuid::from_random_bytes #399

Merged
merged 2 commits into from
Apr 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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