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

Add #[must_use] to applicable math operations #1678

Merged
merged 2 commits into from
May 2, 2023
Merged

Conversation

chipshort
Copy link
Collaborator

closes #1609

@chipshort chipshort changed the base branch from main to 1.2 May 2, 2023 12:08
Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

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

Nice. Just unsure about the trait case.

Can you add a CHANGELOG entry to the Unreleased section as part of the PR?

@@ -10,6 +10,7 @@ pub trait Fraction<T>: Sized {
/// Returns the multiplicative inverse `q/p` for fraction `p/q`.
///
/// If `p` is zero, None is returned.
#[must_use = "this returns the result of the operation, without modifying the original"]
Copy link
Member

Choose a reason for hiding this comment

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

Is this the right place here? Does this belong to the trait definition or the trait implementation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I think it has to go in the trait definition. When I put it on the impl, it does not trigger the warning.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for double checking

@chipshort chipshort merged commit 1915d0e into 1.2 May 2, 2023
@chipshort chipshort deleted the chipshort/issue1609 branch May 2, 2023 13:40
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.

#[must_use] is missing on many methods
2 participants