Windows-rs: Document naming translation conventions

Created on 22 Jan 2021  路  8Comments  路  Source: microsoft/windows-rs

Right now, it seems like WinRT-based APIs have their names converted to match Rust naming conventions, whereas Win32 ones do not. This is an unfortunate style mismatch. It would be nice if all APIs could follow the same idiomatic naming conventions.

documentation

Most helpful comment

Sorry! Didn't mean to close prematurely. Happy to put this in the README! 鉂わ笍

All 8 comments

I would say go the other directions: all raw function declarations should use precisely the original name, and leave the snake_case conversion to wrapper crates or whatever higher level thing people care to use.

Indeed, this is by design. The WinRT subset is converted in such a way as to appear idiomatic because it is a rich wrapper over the underlying ABI. The remaining Win32, and to some degree COM, APIs preserve their original names because they are largely direct calls to the ABI and typically need wrapping of some kind before they can be used idiomatically in Rust.

It's also idiomatic for bindings for C APIs (which win32 APIs are) retain their original casing. The WinRT APIs exposed by windows-rs are wrappers and meant to be (relatively) idiomatic. They call underlying foreign functions but are Rust APIs themselves and thus deserve Rust idiomatic camel casing. I think we can close this issue.

Slow down one moment: What you just said should be put into the readme and at the root level of the crate documents so that people understand what's going on with that.

Sorry! Didn't mean to close prematurely. Happy to put this in the README! 鉂わ笍

Names are no longer converted, so closing this.

@rylev That's interesting. What was the rationale for that? Were misconversions common enough that you decided it wasn't worth the trouble?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

joverwey picture joverwey  路  3Comments

AyashiNoCeres picture AyashiNoCeres  路  4Comments

chuckries picture chuckries  路  3Comments

06393993 picture 06393993  路  3Comments

rylev picture rylev  路  4Comments