-
Notifications
You must be signed in to change notification settings - Fork 112
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
Naming conventions #190
Comments
Awesome! Thanks so much for putting this together and including examples! This looks fine to me. If @kvark doesn't have any issues, want to just PR this into Really like that you included examples, this was easy to follow. Thanks! |
My ❤️ emoji agrees with you! |
What about |
That would be an improvement, I think. |
We want to release gfx-backend-metal very soon. Would anybody want to help with these naming changes in metal-rs? It's not a blocker for us, we can release an intermediate version. |
TLDR
Take Metal Objective C and Swift API and change names to Rust idiomatic names where applicable.
General
Rust bindings are based on Objective C protocol bindings.
Follow Objective C protocol definition to determine properties and methods.
Swift API adds some higher level stuff that is beyond the scope of Rust bindings.
Struct (Object) and Enum names
Same as Objective C/Swift API, e.g.
MTLDevice
,MTLCommandBufferStatus
,MTLCommandBuffer
etc.Enums
Swift
Rust: change variant names following Rust conventions:
(basically capitalize first word)
NOTE: Some enums contain Apple brand names that intentionally start with lowercase.
In those cases respect that, adding necessary #allow to keep Rust happy. For example:
Method names
Objective C
Swift
Rust: change to lowercase snake case:
Special Case
Some methods create new objects (aka factory methods).
Objective C:
Swift:
NOTE: overloading
Rust:
make
tonew
, as we do in Rust:The text was updated successfully, but these errors were encountered: