Restore 'must_use' for 'clamp'; fix warning for tests
This commit is contained in:
parent
54cb728ab8
commit
1aa5d0cace
2 changed files with 8 additions and 10 deletions
|
@ -1015,8 +1015,7 @@ impl f32 {
|
|||
/// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0);
|
||||
/// assert!((std::f32::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"]
|
||||
#[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 {
|
||||
|
@ -1631,18 +1630,18 @@ mod tests {
|
|||
#[test]
|
||||
#[should_panic]
|
||||
fn test_clamp_min_greater_than_max() {
|
||||
1.0f32.clamp(3.0, 1.0);
|
||||
let _ = 1.0f32.clamp(3.0, 1.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_clamp_min_is_nan() {
|
||||
1.0f32.clamp(NAN, 1.0);
|
||||
let _ = 1.0f32.clamp(NAN, 1.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_clamp_max_is_nan() {
|
||||
1.0f32.clamp(3.0, NAN);
|
||||
let _ = 1.0f32.clamp(3.0, NAN);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -936,8 +936,7 @@ 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"]
|
||||
#[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 {
|
||||
|
@ -1571,18 +1570,18 @@ mod tests {
|
|||
#[test]
|
||||
#[should_panic]
|
||||
fn test_clamp_min_greater_than_max() {
|
||||
1.0f64.clamp(3.0, 1.0);
|
||||
let _ = 1.0f64.clamp(3.0, 1.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_clamp_min_is_nan() {
|
||||
1.0f64.clamp(NAN, 1.0);
|
||||
let _ = 1.0f64.clamp(NAN, 1.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_clamp_max_is_nan() {
|
||||
1.0f64.clamp(3.0, NAN);
|
||||
let _ = 1.0f64.clamp(3.0, NAN);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue