Skip to content

Commit

Permalink
Revert "Merge #449"
Browse files Browse the repository at this point in the history
This reverts commit e0c7b17, reversing
changes made to f177d20.
  • Loading branch information
KodrAus committed Dec 21, 2020
1 parent 51930b1 commit 0ab0e6f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/winapi_support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ use winapi::shared::guiddef;

#[cfg(feature = "guid")]
impl Uuid {
/// Converts a little endian winapi `GUID` into a [`Uuid`]
/// Attempts to create a [`Uuid`] from a little endian winapi `GUID`
///
/// [`Uuid`]: ../struct.Uuid.html
pub fn from_guid(guid: guiddef::GUID) -> Self {
pub fn from_guid(guid: guiddef::GUID) -> Result<Uuid, crate::Error> {
Uuid::from_fields_le(
guid.Data1 as u32,
guid.Data2 as u16,
guid.Data3 as u16,
&(guid.Data4 as [u8; 8]),
)
.unwrap() // Note: The result in this particular instance is always Ok,
// so we can safely unwrap.
}

/// Converts a [`Uuid`] into a little endian winapi `GUID`
Expand Down Expand Up @@ -49,7 +47,7 @@ mod tests {
Data4: [0x86, 0x47, 0x9d, 0xc5, 0x4e, 0x1e, 0xe1, 0xe8],
};

let uuid = Uuid::from_guid(guid);
let uuid = Uuid::from_guid(guid).unwrap();
assert_eq!(
"9d22354a-2755-304f-8647-9dc54e1ee1e8",
uuid.to_hyphenated().to_string()
Expand All @@ -65,7 +63,7 @@ mod tests {
Data4: [0x86, 0x47, 0x9d, 0xc5, 0x4e, 0x1e, 0xe1, 0xe8],
};

let uuid = Uuid::from_guid(guid_in);
let uuid = Uuid::from_guid(guid_in).unwrap();
let guid_out = uuid.to_guid();

assert_eq!(
Expand Down

0 comments on commit 0ab0e6f

Please sign in to comment.