-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MTLResourceID::from_raw and MTLResourceID::as_raw
Fixes #660
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::MTLResourceID; | ||
|
||
impl MTLResourceID { | ||
/// Construct a `MTLResourceID` from an ID previously gotten via. | ||
/// `to_raw`. | ||
/// | ||
/// # Safety | ||
/// | ||
/// The documentation for `MTLResourceID` says: | ||
/// | ||
/// > A MTLResourceID represents a specific GPU resource, mutating this | ||
/// > handle is undefined unless the mutation results in the value | ||
/// > equalling an already existing handle of the same resource type. | ||
/// | ||
/// So we've tentatively marked this method as `unsafe`, with the safety | ||
/// requirement that the ID must be valid, i.e. have previously come from | ||
/// [`to_raw`][Self::to_raw] or similar. | ||
/// | ||
/// If you disagree with this assessment, feel free to open an issue! | ||
pub const unsafe fn from_raw(id: u64) -> Self { | ||
Self { _impl: id } | ||
} | ||
|
||
/// Get the underlying data of the ID. | ||
/// | ||
/// May be useful for FFI purposes. | ||
pub const fn to_raw(self) -> u64 { | ||
self._impl | ||
} | ||
} |
94f104f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub doesn't allow commenting on arbitrary lines in commits, so I'm doing it like this:
Shouldn't the dot on the first line be inside backticks, as if you're referencing to the
.to_raw()
method?94f104f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a native speaker, I thought "via" was an abbreviation
94f104f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, then I see why there was a stray
.
there :)94f104f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 67a4acd, and opened crate-ci/typos#1113, thanks!