support the winapi-rs crate by implementing std::convert::From<GUID>. #333

Closed
opened 2018-10-03 22:14:16 -05:00 by kinggoesgaming · 5 comments
kinggoesgaming commented 2018-10-03 22:14:16 -05:00 (Migrated from github.com)
_Originally posted by @lzybkr in https://github.com/uuid-rs/uuid/issues/277#issuecomment-426824514_
KodrAus commented 2018-10-04 00:13:58 -05:00 (Migrated from github.com)

Adding from_guid and to_guid methods to Uuid behind a feature gate (could just use winapi as an optional dependency) could do this:

winapi = { version = "0.3", optional = true }
#[cfg(feature = "winapi")]
mod guid_support {
    use super::Uuid;
    use winapi::shared::guiddef::GUID;

    impl Uuid {
        pub fn from_guid(guid: GUID) -> Self;
        pub fn to_guid(&self) -> GUID;
    }
}
Adding `from_guid` and `to_guid` methods to `Uuid` behind a feature gate (could just use `winapi` as an optional dependency) could do this: ```toml winapi = { version = "0.3", optional = true } ``` ```rust #[cfg(feature = "winapi")] mod guid_support { use super::Uuid; use winapi::shared::guiddef::GUID; impl Uuid { pub fn from_guid(guid: GUID) -> Self; pub fn to_guid(&self) -> GUID; } } ```
KodrAus commented 2018-10-04 00:14:54 -05:00 (Migrated from github.com)

I think explicit methods on Uuid would be preferable to a From impl in this case.

I think explicit methods on `Uuid` would be preferable to a `From` impl in this case.
Redrield commented 2018-10-06 15:18:13 -05:00 (Migrated from github.com)

I could try to pick this up

I could try to pick this up
Dylan-DPC-zz commented 2018-10-06 15:37:00 -05:00 (Migrated from github.com)

@Redrield yeah sure . Go ahead 👍

@Redrield yeah sure . Go ahead :+1:
Redrield commented 2018-10-06 15:41:57 -05:00 (Migrated from github.com)

@Dylan-DPC Do you want this done with a From impl or with methods on Uuid?

@Dylan-DPC Do you want this done with a From impl or with methods on Uuid?
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-uuid-rs/uuid#333
No description provided.