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

Add as_raw to windows-registry #3003

Merged
merged 1 commit into from
Apr 18, 2024
Merged

Add as_raw to windows-registry #3003

merged 1 commit into from
Apr 18, 2024

Conversation

kennykerr
Copy link
Collaborator

This returns the underlying registry key handle for interop purposes.

Fixes: #2999

@kennykerr kennykerr merged commit a729410 into master Apr 18, 2024
71 checks passed
@kennykerr kennykerr deleted the registry-as-raw branch April 18, 2024 18:14
Comment on lines +41 to +43
pub fn as_raw(&self) -> isize {
self.0
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This duplicates the key handle but Key also implements Drop potentially leaving callers with an invalid handle. Should this be unsafe?

Alternatively, this could be pub fn into_inner(self) -> isize instead making the transfer of ownership obvious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no transfer of ownership here. This is similar to https://doc.rust-lang.org/stable/std/vec/struct.Vec.html#method.as_ptr where the underlying value is returned without changing ownership and requiring the caller to use it judiciously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants