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

signals: use #[must_use] when returning a QMetaObjectConnectionGuard #932

Merged

Conversation

ahayzen-kdab
Copy link
Collaborator

Before we used to return a QMetaObjectConnection which used to disconnection now we have two types, so ensure #[must_use] is in the right place.

Closes #930

Copy link

@greaka greaka left a comment

Choose a reason for hiding this comment

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

It is easy to miss adding #[must_use] when adding a new signal.
By annotating QMetaObjectConnectionGuard instead, the must_use warning will automatically be applied to every function that returns that struct.

While both changing the return type and adding new functions is equally unlikely, putting must_use on the type also helps downstream users when working with this type.

@ahayzen-kdab
Copy link
Collaborator Author

Good idea, i'll try that :-)

@ahayzen-kdab ahayzen-kdab force-pushed the 930-must-use-for-connection-guard branch from d442859 to 578926c Compare April 18, 2024 09:07
Before we used to return a QMetaObjectConnection which used to
disconnection now we have two types, so ensure #[must_use] is
used when a guard is returned.
@ahayzen-kdab ahayzen-kdab force-pushed the 930-must-use-for-connection-guard branch from 578926c to 5f094e7 Compare April 18, 2024 09:25
Copy link
Collaborator

@LeonMatthesKDAB LeonMatthesKDAB left a comment

Choose a reason for hiding this comment

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

Really good suggestion by @greaka

@ahayzen-kdab ahayzen-kdab merged commit 277db19 into KDAB:main Apr 19, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants