@@ -40,6 +40,7 @@ impl f32 {
4040 /// assert_eq!(g.floor(), 3.0);
4141 /// assert_eq!(h.floor(), -4.0);
4242 /// ```
43+ #[ must_use = "method returns a new number and does not mutate the original value" ]
4344 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
4445 #[ inline]
4546 pub fn floor ( self ) -> f32 {
@@ -73,6 +74,7 @@ impl f32 {
7374 /// assert_eq!(f.ceil(), 4.0);
7475 /// assert_eq!(g.ceil(), 4.0);
7576 /// ```
77+ #[ must_use = "method returns a new number and does not mutate the original value" ]
7678 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
7779 #[ inline]
7880 pub fn ceil ( self ) -> f32 {
@@ -95,6 +97,7 @@ impl f32 {
9597 /// assert_eq!(f.round(), 3.0);
9698 /// assert_eq!(g.round(), -3.0);
9799 /// ```
100+ #[ must_use = "method returns a new number and does not mutate the original value" ]
98101 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
99102 #[ inline]
100103 pub fn round ( self ) -> f32 {
@@ -114,6 +117,7 @@ impl f32 {
114117 /// assert_eq!(g.trunc(), 3.0);
115118 /// assert_eq!(h.trunc(), -3.0);
116119 /// ```
120+ #[ must_use = "method returns a new number and does not mutate the original value" ]
117121 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
118122 #[ inline]
119123 pub fn trunc ( self ) -> f32 {
@@ -135,6 +139,7 @@ impl f32 {
135139 /// assert!(abs_difference_x <= f32::EPSILON);
136140 /// assert!(abs_difference_y <= f32::EPSILON);
137141 /// ```
142+ #[ must_use = "method returns a new number and does not mutate the original value" ]
138143 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
139144 #[ inline]
140145 pub fn fract ( self ) -> f32 { self - self . trunc ( ) }
@@ -158,6 +163,7 @@ impl f32 {
158163 ///
159164 /// assert!(f32::NAN.abs().is_nan());
160165 /// ```
166+ #[ must_use = "method returns a new number and does not mutate the original value" ]
161167 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
162168 #[ inline]
163169 pub fn abs ( self ) -> f32 {
@@ -182,6 +188,7 @@ impl f32 {
182188 ///
183189 /// assert!(f32::NAN.signum().is_nan());
184190 /// ```
191+ #[ must_use = "method returns a new number and does not mutate the original value" ]
185192 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
186193 #[ inline]
187194 pub fn signum ( self ) -> f32 {
@@ -213,8 +220,8 @@ impl f32 {
213220 ///
214221 /// assert!(f32::NAN.copysign(1.0).is_nan());
215222 /// ```
223+ #[ must_use = "method returns a new number and does not mutate the original value" ]
216224 #[ inline]
217- #[ must_use]
218225 #[ stable( feature = "copysign" , since = "1.35.0" ) ]
219226 pub fn copysign ( self , sign : f32 ) -> f32 {
220227 unsafe { intrinsics:: copysignf32 ( self , sign) }
@@ -240,6 +247,7 @@ impl f32 {
240247 ///
241248 /// assert!(abs_difference <= f32::EPSILON);
242249 /// ```
250+ #[ must_use = "method returns a new number and does not mutate the original value" ]
243251 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
244252 #[ inline]
245253 pub fn mul_add ( self , a : f32 , b : f32 ) -> f32 {
@@ -263,6 +271,7 @@ impl f32 {
263271 /// assert_eq!(a.div_euclid(-b), -1.0); // 7.0 >= -4.0 * -1.0
264272 /// assert_eq!((-a).div_euclid(-b), 2.0); // -7.0 >= -4.0 * 2.0
265273 /// ```
274+ #[ must_use = "method returns a new number and does not mutate the original value" ]
266275 #[ inline]
267276 #[ stable( feature = "euclidean_division" , since = "1.38.0" ) ]
268277 pub fn div_euclid ( self , rhs : f32 ) -> f32 {
@@ -296,6 +305,7 @@ impl f32 {
296305 /// // limitation due to round-off error
297306 /// assert!((-std::f32::EPSILON).rem_euclid(3.0) != 0.0);
298307 /// ```
308+ #[ must_use = "method returns a new number and does not mutate the original value" ]
299309 #[ inline]
300310 #[ stable( feature = "euclidean_division" , since = "1.38.0" ) ]
301311 pub fn rem_euclid ( self , rhs : f32 ) -> f32 {
@@ -322,6 +332,7 @@ impl f32 {
322332 ///
323333 /// assert!(abs_difference <= f32::EPSILON);
324334 /// ```
335+ #[ must_use = "method returns a new number and does not mutate the original value" ]
325336 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
326337 #[ inline]
327338 pub fn powi ( self , n : i32 ) -> f32 {
@@ -340,6 +351,7 @@ impl f32 {
340351 ///
341352 /// assert!(abs_difference <= f32::EPSILON);
342353 /// ```
354+ #[ must_use = "method returns a new number and does not mutate the original value" ]
343355 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
344356 #[ inline]
345357 pub fn powf ( self , n : f32 ) -> f32 {
@@ -367,6 +379,7 @@ impl f32 {
367379 /// assert!(abs_difference <= f32::EPSILON);
368380 /// assert!(negative.sqrt().is_nan());
369381 /// ```
382+ #[ must_use = "method returns a new number and does not mutate the original value" ]
370383 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
371384 #[ inline]
372385 pub fn sqrt ( self ) -> f32 {
@@ -393,6 +406,7 @@ impl f32 {
393406 ///
394407 /// assert!(abs_difference <= f32::EPSILON);
395408 /// ```
409+ #[ must_use = "method returns a new number and does not mutate the original value" ]
396410 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
397411 #[ inline]
398412 pub fn exp ( self ) -> f32 {
@@ -417,6 +431,7 @@ impl f32 {
417431 ///
418432 /// assert!(abs_difference <= f32::EPSILON);
419433 /// ```
434+ #[ must_use = "method returns a new number and does not mutate the original value" ]
420435 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
421436 #[ inline]
422437 pub fn exp2 ( self ) -> f32 {
@@ -439,6 +454,7 @@ impl f32 {
439454 ///
440455 /// assert!(abs_difference <= f32::EPSILON);
441456 /// ```
457+ #[ must_use = "method returns a new number and does not mutate the original value" ]
442458 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
443459 #[ inline]
444460 pub fn ln ( self ) -> f32 {
@@ -467,6 +483,7 @@ impl f32 {
467483 ///
468484 /// assert!(abs_difference <= f32::EPSILON);
469485 /// ```
486+ #[ must_use = "method returns a new number and does not mutate the original value" ]
470487 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
471488 #[ inline]
472489 pub fn log ( self , base : f32 ) -> f32 { self . ln ( ) / base. ln ( ) }
@@ -485,6 +502,7 @@ impl f32 {
485502 ///
486503 /// assert!(abs_difference <= f32::EPSILON);
487504 /// ```
505+ #[ must_use = "method returns a new number and does not mutate the original value" ]
488506 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
489507 #[ inline]
490508 pub fn log2 ( self ) -> f32 {
@@ -508,6 +526,7 @@ impl f32 {
508526 ///
509527 /// assert!(abs_difference <= f32::EPSILON);
510528 /// ```
529+ #[ must_use = "method returns a new number and does not mutate the original value" ]
511530 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
512531 #[ inline]
513532 pub fn log10 ( self ) -> f32 {
@@ -537,6 +556,7 @@ impl f32 {
537556 /// assert!(abs_difference_x <= f32::EPSILON);
538557 /// assert!(abs_difference_y <= f32::EPSILON);
539558 /// ```
559+ #[ must_use = "method returns a new number and does not mutate the original value" ]
540560 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
541561 #[ inline]
542562 #[ rustc_deprecated( since = "1.10.0" ,
@@ -565,6 +585,7 @@ impl f32 {
565585 ///
566586 /// assert!(abs_difference <= f32::EPSILON);
567587 /// ```
588+ #[ must_use = "method returns a new number and does not mutate the original value" ]
568589 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
569590 #[ inline]
570591 pub fn cbrt ( self ) -> f32 {
@@ -587,6 +608,7 @@ impl f32 {
587608 ///
588609 /// assert!(abs_difference <= f32::EPSILON);
589610 /// ```
611+ #[ must_use = "method returns a new number and does not mutate the original value" ]
590612 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
591613 #[ inline]
592614 pub fn hypot ( self , other : f32 ) -> f32 {
@@ -606,6 +628,7 @@ impl f32 {
606628 ///
607629 /// assert!(abs_difference <= f32::EPSILON);
608630 /// ```
631+ #[ must_use = "method returns a new number and does not mutate the original value" ]
609632 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
610633 #[ inline]
611634 pub fn sin ( self ) -> f32 {
@@ -629,6 +652,7 @@ impl f32 {
629652 ///
630653 /// assert!(abs_difference <= f32::EPSILON);
631654 /// ```
655+ #[ must_use = "method returns a new number and does not mutate the original value" ]
632656 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
633657 #[ inline]
634658 pub fn cos ( self ) -> f32 {
@@ -651,6 +675,7 @@ impl f32 {
651675 ///
652676 /// assert!(abs_difference <= f32::EPSILON);
653677 /// ```
678+ #[ must_use = "method returns a new number and does not mutate the original value" ]
654679 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
655680 #[ inline]
656681 pub fn tan ( self ) -> f32 {
@@ -673,6 +698,7 @@ impl f32 {
673698 ///
674699 /// assert!(abs_difference <= f32::EPSILON);
675700 /// ```
701+ #[ must_use = "method returns a new number and does not mutate the original value" ]
676702 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
677703 #[ inline]
678704 pub fn asin ( self ) -> f32 {
@@ -695,6 +721,7 @@ impl f32 {
695721 ///
696722 /// assert!(abs_difference <= f32::EPSILON);
697723 /// ```
724+ #[ must_use = "method returns a new number and does not mutate the original value" ]
698725 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
699726 #[ inline]
700727 pub fn acos ( self ) -> f32 {
@@ -716,6 +743,7 @@ impl f32 {
716743 ///
717744 /// assert!(abs_difference <= f32::EPSILON);
718745 /// ```
746+ #[ must_use = "method returns a new number and does not mutate the original value" ]
719747 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
720748 #[ inline]
721749 pub fn atan ( self ) -> f32 {
@@ -750,6 +778,7 @@ impl f32 {
750778 /// assert!(abs_difference_1 <= f32::EPSILON);
751779 /// assert!(abs_difference_2 <= f32::EPSILON);
752780 /// ```
781+ #[ must_use = "method returns a new number and does not mutate the original value" ]
753782 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
754783 #[ inline]
755784 pub fn atan2 ( self , other : f32 ) -> f32 {
@@ -794,6 +823,7 @@ impl f32 {
794823 ///
795824 /// assert!(abs_difference <= f32::EPSILON);
796825 /// ```
826+ #[ must_use = "method returns a new number and does not mutate the original value" ]
797827 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
798828 #[ inline]
799829 pub fn exp_m1 ( self ) -> f32 {
@@ -815,6 +845,7 @@ impl f32 {
815845 ///
816846 /// assert!(abs_difference <= f32::EPSILON);
817847 /// ```
848+ #[ must_use = "method returns a new number and does not mutate the original value" ]
818849 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
819850 #[ inline]
820851 pub fn ln_1p ( self ) -> f32 {
@@ -838,6 +869,7 @@ impl f32 {
838869 ///
839870 /// assert!(abs_difference <= f32::EPSILON);
840871 /// ```
872+ #[ must_use = "method returns a new number and does not mutate the original value" ]
841873 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
842874 #[ inline]
843875 pub fn sinh ( self ) -> f32 {
@@ -861,6 +893,7 @@ impl f32 {
861893 /// // Same result
862894 /// assert!(abs_difference <= f32::EPSILON);
863895 /// ```
896+ #[ must_use = "method returns a new number and does not mutate the original value" ]
864897 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
865898 #[ inline]
866899 pub fn cosh ( self ) -> f32 {
@@ -884,6 +917,7 @@ impl f32 {
884917 ///
885918 /// assert!(abs_difference <= f32::EPSILON);
886919 /// ```
920+ #[ must_use = "method returns a new number and does not mutate the original value" ]
887921 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
888922 #[ inline]
889923 pub fn tanh ( self ) -> f32 {
@@ -904,6 +938,7 @@ impl f32 {
904938 ///
905939 /// assert!(abs_difference <= f32::EPSILON);
906940 /// ```
941+ #[ must_use = "method returns a new number and does not mutate the original value" ]
907942 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
908943 #[ inline]
909944 pub fn asinh ( self ) -> f32 {
@@ -928,6 +963,7 @@ impl f32 {
928963 ///
929964 /// assert!(abs_difference <= f32::EPSILON);
930965 /// ```
966+ #[ must_use = "method returns a new number and does not mutate the original value" ]
931967 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
932968 #[ inline]
933969 pub fn acosh ( self ) -> f32 {
@@ -952,6 +988,7 @@ impl f32 {
952988 ///
953989 /// assert!(abs_difference <= 1e-5);
954990 /// ```
991+ #[ must_use = "method returns a new number and does not mutate the original value" ]
955992 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
956993 #[ inline]
957994 pub fn atanh ( self ) -> f32 {
@@ -979,6 +1016,7 @@ impl f32 {
9791016 /// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0);
9801017 /// assert!((std::f32::NAN).clamp(-2.0, 1.0).is_nan());
9811018 /// ```
1019+ #[ must_use = "method returns a new number and does not mutate the original value" ]
9821020 #[ unstable( feature = "clamp" , issue = "44095" ) ]
9831021 #[ inline]
9841022 pub fn clamp ( self , min : f32 , max : f32 ) -> f32 {
@@ -1594,18 +1632,18 @@ mod tests {
15941632 #[ test]
15951633 #[ should_panic]
15961634 fn test_clamp_min_greater_than_max ( ) {
1597- 1.0f32 . clamp ( 3.0 , 1.0 ) ;
1635+ let _ = 1.0f32 . clamp ( 3.0 , 1.0 ) ;
15981636 }
15991637
16001638 #[ test]
16011639 #[ should_panic]
16021640 fn test_clamp_min_is_nan ( ) {
1603- 1.0f32 . clamp ( NAN , 1.0 ) ;
1641+ let _ = 1.0f32 . clamp ( NAN , 1.0 ) ;
16041642 }
16051643
16061644 #[ test]
16071645 #[ should_panic]
16081646 fn test_clamp_max_is_nan ( ) {
1609- 1.0f32 . clamp ( 3.0 , NAN ) ;
1647+ let _ = 1.0f32 . clamp ( 3.0 , NAN ) ;
16101648 }
16111649}
0 commit comments