@@ -40,6 +40,7 @@ impl f32 {
40
40
/// assert_eq!(g.floor(), 3.0);
41
41
/// assert_eq!(h.floor(), -4.0);
42
42
/// ```
43
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
43
44
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
44
45
#[ inline]
45
46
pub fn floor ( self ) -> f32 {
@@ -73,6 +74,7 @@ impl f32 {
73
74
/// assert_eq!(f.ceil(), 4.0);
74
75
/// assert_eq!(g.ceil(), 4.0);
75
76
/// ```
77
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
76
78
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
77
79
#[ inline]
78
80
pub fn ceil ( self ) -> f32 {
@@ -95,6 +97,7 @@ impl f32 {
95
97
/// assert_eq!(f.round(), 3.0);
96
98
/// assert_eq!(g.round(), -3.0);
97
99
/// ```
100
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
98
101
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
99
102
#[ inline]
100
103
pub fn round ( self ) -> f32 {
@@ -114,6 +117,7 @@ impl f32 {
114
117
/// assert_eq!(g.trunc(), 3.0);
115
118
/// assert_eq!(h.trunc(), -3.0);
116
119
/// ```
120
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
117
121
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
118
122
#[ inline]
119
123
pub fn trunc ( self ) -> f32 {
@@ -135,6 +139,7 @@ impl f32 {
135
139
/// assert!(abs_difference_x <= f32::EPSILON);
136
140
/// assert!(abs_difference_y <= f32::EPSILON);
137
141
/// ```
142
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
138
143
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
139
144
#[ inline]
140
145
pub fn fract ( self ) -> f32 { self - self . trunc ( ) }
@@ -158,6 +163,7 @@ impl f32 {
158
163
///
159
164
/// assert!(f32::NAN.abs().is_nan());
160
165
/// ```
166
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
161
167
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
162
168
#[ inline]
163
169
pub fn abs ( self ) -> f32 {
@@ -182,6 +188,7 @@ impl f32 {
182
188
///
183
189
/// assert!(f32::NAN.signum().is_nan());
184
190
/// ```
191
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
185
192
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
186
193
#[ inline]
187
194
pub fn signum ( self ) -> f32 {
@@ -213,8 +220,8 @@ impl f32 {
213
220
///
214
221
/// assert!(f32::NAN.copysign(1.0).is_nan());
215
222
/// ```
223
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
216
224
#[ inline]
217
- #[ must_use]
218
225
#[ stable( feature = "copysign" , since = "1.35.0" ) ]
219
226
pub fn copysign ( self , sign : f32 ) -> f32 {
220
227
unsafe { intrinsics:: copysignf32 ( self , sign) }
@@ -240,6 +247,7 @@ impl f32 {
240
247
///
241
248
/// assert!(abs_difference <= f32::EPSILON);
242
249
/// ```
250
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
243
251
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
244
252
#[ inline]
245
253
pub fn mul_add ( self , a : f32 , b : f32 ) -> f32 {
@@ -263,6 +271,7 @@ impl f32 {
263
271
/// assert_eq!(a.div_euclid(-b), -1.0); // 7.0 >= -4.0 * -1.0
264
272
/// assert_eq!((-a).div_euclid(-b), 2.0); // -7.0 >= -4.0 * 2.0
265
273
/// ```
274
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
266
275
#[ inline]
267
276
#[ stable( feature = "euclidean_division" , since = "1.38.0" ) ]
268
277
pub fn div_euclid ( self , rhs : f32 ) -> f32 {
@@ -296,6 +305,7 @@ impl f32 {
296
305
/// // limitation due to round-off error
297
306
/// assert!((-std::f32::EPSILON).rem_euclid(3.0) != 0.0);
298
307
/// ```
308
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
299
309
#[ inline]
300
310
#[ stable( feature = "euclidean_division" , since = "1.38.0" ) ]
301
311
pub fn rem_euclid ( self , rhs : f32 ) -> f32 {
@@ -322,6 +332,7 @@ impl f32 {
322
332
///
323
333
/// assert!(abs_difference <= f32::EPSILON);
324
334
/// ```
335
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
325
336
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
326
337
#[ inline]
327
338
pub fn powi ( self , n : i32 ) -> f32 {
@@ -340,6 +351,7 @@ impl f32 {
340
351
///
341
352
/// assert!(abs_difference <= f32::EPSILON);
342
353
/// ```
354
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
343
355
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
344
356
#[ inline]
345
357
pub fn powf ( self , n : f32 ) -> f32 {
@@ -367,6 +379,7 @@ impl f32 {
367
379
/// assert!(abs_difference <= f32::EPSILON);
368
380
/// assert!(negative.sqrt().is_nan());
369
381
/// ```
382
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
370
383
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
371
384
#[ inline]
372
385
pub fn sqrt ( self ) -> f32 {
@@ -393,6 +406,7 @@ impl f32 {
393
406
///
394
407
/// assert!(abs_difference <= f32::EPSILON);
395
408
/// ```
409
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
396
410
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
397
411
#[ inline]
398
412
pub fn exp ( self ) -> f32 {
@@ -417,6 +431,7 @@ impl f32 {
417
431
///
418
432
/// assert!(abs_difference <= f32::EPSILON);
419
433
/// ```
434
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
420
435
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
421
436
#[ inline]
422
437
pub fn exp2 ( self ) -> f32 {
@@ -439,6 +454,7 @@ impl f32 {
439
454
///
440
455
/// assert!(abs_difference <= f32::EPSILON);
441
456
/// ```
457
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
442
458
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
443
459
#[ inline]
444
460
pub fn ln ( self ) -> f32 {
@@ -467,6 +483,7 @@ impl f32 {
467
483
///
468
484
/// assert!(abs_difference <= f32::EPSILON);
469
485
/// ```
486
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
470
487
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
471
488
#[ inline]
472
489
pub fn log ( self , base : f32 ) -> f32 { self . ln ( ) / base. ln ( ) }
@@ -485,6 +502,7 @@ impl f32 {
485
502
///
486
503
/// assert!(abs_difference <= f32::EPSILON);
487
504
/// ```
505
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
488
506
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
489
507
#[ inline]
490
508
pub fn log2 ( self ) -> f32 {
@@ -508,6 +526,7 @@ impl f32 {
508
526
///
509
527
/// assert!(abs_difference <= f32::EPSILON);
510
528
/// ```
529
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
511
530
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
512
531
#[ inline]
513
532
pub fn log10 ( self ) -> f32 {
@@ -537,6 +556,7 @@ impl f32 {
537
556
/// assert!(abs_difference_x <= f32::EPSILON);
538
557
/// assert!(abs_difference_y <= f32::EPSILON);
539
558
/// ```
559
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
540
560
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
541
561
#[ inline]
542
562
#[ rustc_deprecated( since = "1.10.0" ,
@@ -565,6 +585,7 @@ impl f32 {
565
585
///
566
586
/// assert!(abs_difference <= f32::EPSILON);
567
587
/// ```
588
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
568
589
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
569
590
#[ inline]
570
591
pub fn cbrt ( self ) -> f32 {
@@ -587,6 +608,7 @@ impl f32 {
587
608
///
588
609
/// assert!(abs_difference <= f32::EPSILON);
589
610
/// ```
611
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
590
612
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
591
613
#[ inline]
592
614
pub fn hypot ( self , other : f32 ) -> f32 {
@@ -606,6 +628,7 @@ impl f32 {
606
628
///
607
629
/// assert!(abs_difference <= f32::EPSILON);
608
630
/// ```
631
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
609
632
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
610
633
#[ inline]
611
634
pub fn sin ( self ) -> f32 {
@@ -629,6 +652,7 @@ impl f32 {
629
652
///
630
653
/// assert!(abs_difference <= f32::EPSILON);
631
654
/// ```
655
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
632
656
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
633
657
#[ inline]
634
658
pub fn cos ( self ) -> f32 {
@@ -651,6 +675,7 @@ impl f32 {
651
675
///
652
676
/// assert!(abs_difference <= f32::EPSILON);
653
677
/// ```
678
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
654
679
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
655
680
#[ inline]
656
681
pub fn tan ( self ) -> f32 {
@@ -673,6 +698,7 @@ impl f32 {
673
698
///
674
699
/// assert!(abs_difference <= f32::EPSILON);
675
700
/// ```
701
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
676
702
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
677
703
#[ inline]
678
704
pub fn asin ( self ) -> f32 {
@@ -695,6 +721,7 @@ impl f32 {
695
721
///
696
722
/// assert!(abs_difference <= f32::EPSILON);
697
723
/// ```
724
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
698
725
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
699
726
#[ inline]
700
727
pub fn acos ( self ) -> f32 {
@@ -716,6 +743,7 @@ impl f32 {
716
743
///
717
744
/// assert!(abs_difference <= f32::EPSILON);
718
745
/// ```
746
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
719
747
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
720
748
#[ inline]
721
749
pub fn atan ( self ) -> f32 {
@@ -750,6 +778,7 @@ impl f32 {
750
778
/// assert!(abs_difference_1 <= f32::EPSILON);
751
779
/// assert!(abs_difference_2 <= f32::EPSILON);
752
780
/// ```
781
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
753
782
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
754
783
#[ inline]
755
784
pub fn atan2 ( self , other : f32 ) -> f32 {
@@ -794,6 +823,7 @@ impl f32 {
794
823
///
795
824
/// assert!(abs_difference <= f32::EPSILON);
796
825
/// ```
826
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
797
827
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
798
828
#[ inline]
799
829
pub fn exp_m1 ( self ) -> f32 {
@@ -815,6 +845,7 @@ impl f32 {
815
845
///
816
846
/// assert!(abs_difference <= f32::EPSILON);
817
847
/// ```
848
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
818
849
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
819
850
#[ inline]
820
851
pub fn ln_1p ( self ) -> f32 {
@@ -838,6 +869,7 @@ impl f32 {
838
869
///
839
870
/// assert!(abs_difference <= f32::EPSILON);
840
871
/// ```
872
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
841
873
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
842
874
#[ inline]
843
875
pub fn sinh ( self ) -> f32 {
@@ -861,6 +893,7 @@ impl f32 {
861
893
/// // Same result
862
894
/// assert!(abs_difference <= f32::EPSILON);
863
895
/// ```
896
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
864
897
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
865
898
#[ inline]
866
899
pub fn cosh ( self ) -> f32 {
@@ -884,6 +917,7 @@ impl f32 {
884
917
///
885
918
/// assert!(abs_difference <= f32::EPSILON);
886
919
/// ```
920
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
887
921
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
888
922
#[ inline]
889
923
pub fn tanh ( self ) -> f32 {
@@ -904,6 +938,7 @@ impl f32 {
904
938
///
905
939
/// assert!(abs_difference <= f32::EPSILON);
906
940
/// ```
941
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
907
942
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
908
943
#[ inline]
909
944
pub fn asinh ( self ) -> f32 {
@@ -928,6 +963,7 @@ impl f32 {
928
963
///
929
964
/// assert!(abs_difference <= f32::EPSILON);
930
965
/// ```
966
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
931
967
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
932
968
#[ inline]
933
969
pub fn acosh ( self ) -> f32 {
@@ -952,6 +988,7 @@ impl f32 {
952
988
///
953
989
/// assert!(abs_difference <= 1e-5);
954
990
/// ```
991
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
955
992
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
956
993
#[ inline]
957
994
pub fn atanh ( self ) -> f32 {
@@ -979,6 +1016,7 @@ impl f32 {
979
1016
/// assert!((2.0f32).clamp(-2.0, 1.0) == 1.0);
980
1017
/// assert!((std::f32::NAN).clamp(-2.0, 1.0).is_nan());
981
1018
/// ```
1019
+ #[ must_use = "method returns a new number and does not mutate the original value" ]
982
1020
#[ unstable( feature = "clamp" , issue = "44095" ) ]
983
1021
#[ inline]
984
1022
pub fn clamp ( self , min : f32 , max : f32 ) -> f32 {
@@ -1594,18 +1632,18 @@ mod tests {
1594
1632
#[ test]
1595
1633
#[ should_panic]
1596
1634
fn test_clamp_min_greater_than_max ( ) {
1597
- 1.0f32 . clamp ( 3.0 , 1.0 ) ;
1635
+ let _ = 1.0f32 . clamp ( 3.0 , 1.0 ) ;
1598
1636
}
1599
1637
1600
1638
#[ test]
1601
1639
#[ should_panic]
1602
1640
fn test_clamp_min_is_nan ( ) {
1603
- 1.0f32 . clamp ( NAN , 1.0 ) ;
1641
+ let _ = 1.0f32 . clamp ( NAN , 1.0 ) ;
1604
1642
}
1605
1643
1606
1644
#[ test]
1607
1645
#[ should_panic]
1608
1646
fn test_clamp_max_is_nan ( ) {
1609
- 1.0f32 . clamp ( 3.0 , NAN ) ;
1647
+ let _ = 1.0f32 . clamp ( 3.0 , NAN ) ;
1610
1648
}
1611
1649
}
0 commit comments