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 all functions 'fn(float) -> float' #63871

Merged
merged 5 commits into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/libstd/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,8 @@ impl f32 {
/// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0);
/// assert!((std::f32::NAN).clamp(-2.0, 1.0).is_nan());
/// ```
#[must_use = "method returns a new number and does not mutate the original value"]
// The tests below invoke `clamp` without a return value in order to cause a `panic`.
Copy link
Contributor

@fbstj fbstj Aug 29, 2019

Choose a reason for hiding this comment

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

are these worthy of FIXME or some kind of (new?) issue number?

// #[must_use = "method returns a new number and does not mutate the original value"]
#[unstable(feature = "clamp", issue = "44095")]
#[inline]
pub fn clamp(self, min: f32, max: f32) -> f32 {
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,8 @@ impl f64 {
/// assert!((2.0f64).clamp(-2.0, 1.0) == 1.0);
/// assert!((std::f64::NAN).clamp(-2.0, 1.0).is_nan());
/// ```
// The tests below invoke `clamp` without a return value in order to cause a `panic`.
// #[must_use = "method returns a new number and does not mutate the original value"]
#[unstable(feature = "clamp", issue = "44095")]
#[inline]
pub fn clamp(self, min: f64, max: f64) -> f64 {
Expand Down