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

Move use statements to beginning of widgets.rs #2631

Merged
merged 2 commits into from
Feb 11, 2025
Merged

Conversation

randomPoison
Copy link
Collaborator

I think the convention is to put use statements (including pub use) towards the top of the file under the mod statements.

@michael-kerscher
Copy link
Collaborator

I usually put mod after use so I tried to find some official guidance here and found this in the rust style guide.
https://doc.rust-lang.org/style-guide/items.html#:~:text=Put%20imports%20before%20module%20declarations

Put imports before module declarations

@randomPoison
Copy link
Collaborator Author

Oh you're absolutely right. I spaced on that because they're pub use statements, but they also go at the top generally.

@michael-kerscher
Copy link
Collaborator

michael-kerscher commented Feb 8, 2025

I noticed that we have other slides showing what you first attempted - and probably we should follow one style in this.

Actually when thinking more deeply about this - I'm not sure why the style guide proposes that style. The compiler has no problem with both versions but the mod statement first introduced the module to the compiler, only then it can be used by the use.

Copy link
Collaborator

@michael-kerscher michael-kerscher left a comment

Choose a reason for hiding this comment

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

I'm going with the official rust style guide here and approve it in this order

@randomPoison
Copy link
Collaborator Author

Yeah I think sticking with the style guide is the right move 👍

@randomPoison randomPoison merged commit d998022 into main Feb 11, 2025
37 checks passed
@randomPoison randomPoison deleted the legare/move-use branch February 11, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants