slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.88k stars 560 forks source link

Better naming etc. in Rust crate #5882

Open Enyium opened 3 weeks ago

Enyium commented 3 weeks ago

I find some parts of Slint's API to not properly follow Rust's conventions. Here are some things that stood out to me:

To make for a seamless transition, you could duplicate the functions where the ones with the old names call through to the ones with the new names, which would contain the current implementations. The functions with the old names then get a #[deprecated] attribute with a message saying what is to be used instead and that the function will be removed in Slint v2. This way, users get warnings with nice messages what to replace what with, while Slint v1 is still the current major version.

EDIT:

ogoffart commented 3 weeks ago

Thanks for the suggestion.

I think most of it make sense, and it can indeed be done by adding a new and deprecating the old one. Although i don't think that can be done for trait method

row_data() to row()

Not sure about this one. row() could be mistaken with the row number.

property getters use that prefix. I understand that using no prefix/suffix at all makes name conflicts with other methods possible that generated types may provide. Maybe Slint could use a prop_ prefix instead?

I think it's fine to break the guideline in this case.