Skip to content

Commit 6b02362

Browse files
author
Kyle Strand
committed
Add 'must_use' to all functions 'fn(float) -> float'
1 parent eeba189 commit 6b02362

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

src/libstd/f32.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ impl f32 {
4040
/// assert_eq!(g.floor(), 3.0);
4141
/// assert_eq!(h.floor(), -4.0);
4242
/// ```
43+
#[must_use]
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]
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]
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]
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]
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]
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]
185192
#[stable(feature = "rust1", since = "1.0.0")]
186193
#[inline]
187194
pub fn signum(self) -> f32 {
@@ -367,6 +374,7 @@ impl f32 {
367374
/// assert!(abs_difference <= f32::EPSILON);
368375
/// assert!(negative.sqrt().is_nan());
369376
/// ```
377+
#[must_use]
370378
#[stable(feature = "rust1", since = "1.0.0")]
371379
#[inline]
372380
pub fn sqrt(self) -> f32 {
@@ -393,6 +401,7 @@ impl f32 {
393401
///
394402
/// assert!(abs_difference <= f32::EPSILON);
395403
/// ```
404+
#[must_use]
396405
#[stable(feature = "rust1", since = "1.0.0")]
397406
#[inline]
398407
pub fn exp(self) -> f32 {
@@ -417,6 +426,7 @@ impl f32 {
417426
///
418427
/// assert!(abs_difference <= f32::EPSILON);
419428
/// ```
429+
#[must_use]
420430
#[stable(feature = "rust1", since = "1.0.0")]
421431
#[inline]
422432
pub fn exp2(self) -> f32 {
@@ -439,6 +449,7 @@ impl f32 {
439449
///
440450
/// assert!(abs_difference <= f32::EPSILON);
441451
/// ```
452+
#[must_use]
442453
#[stable(feature = "rust1", since = "1.0.0")]
443454
#[inline]
444455
pub fn ln(self) -> f32 {
@@ -485,6 +496,7 @@ impl f32 {
485496
///
486497
/// assert!(abs_difference <= f32::EPSILON);
487498
/// ```
499+
#[must_use]
488500
#[stable(feature = "rust1", since = "1.0.0")]
489501
#[inline]
490502
pub fn log2(self) -> f32 {
@@ -508,6 +520,7 @@ impl f32 {
508520
///
509521
/// assert!(abs_difference <= f32::EPSILON);
510522
/// ```
523+
#[must_use]
511524
#[stable(feature = "rust1", since = "1.0.0")]
512525
#[inline]
513526
pub fn log10(self) -> f32 {
@@ -565,6 +578,7 @@ impl f32 {
565578
///
566579
/// assert!(abs_difference <= f32::EPSILON);
567580
/// ```
581+
#[must_use]
568582
#[stable(feature = "rust1", since = "1.0.0")]
569583
#[inline]
570584
pub fn cbrt(self) -> f32 {
@@ -606,6 +620,7 @@ impl f32 {
606620
///
607621
/// assert!(abs_difference <= f32::EPSILON);
608622
/// ```
623+
#[must_use]
609624
#[stable(feature = "rust1", since = "1.0.0")]
610625
#[inline]
611626
pub fn sin(self) -> f32 {
@@ -629,6 +644,7 @@ impl f32 {
629644
///
630645
/// assert!(abs_difference <= f32::EPSILON);
631646
/// ```
647+
#[must_use]
632648
#[stable(feature = "rust1", since = "1.0.0")]
633649
#[inline]
634650
pub fn cos(self) -> f32 {
@@ -651,6 +667,7 @@ impl f32 {
651667
///
652668
/// assert!(abs_difference <= f32::EPSILON);
653669
/// ```
670+
#[must_use]
654671
#[stable(feature = "rust1", since = "1.0.0")]
655672
#[inline]
656673
pub fn tan(self) -> f32 {
@@ -673,6 +690,7 @@ impl f32 {
673690
///
674691
/// assert!(abs_difference <= f32::EPSILON);
675692
/// ```
693+
#[must_use]
676694
#[stable(feature = "rust1", since = "1.0.0")]
677695
#[inline]
678696
pub fn asin(self) -> f32 {
@@ -695,6 +713,7 @@ impl f32 {
695713
///
696714
/// assert!(abs_difference <= f32::EPSILON);
697715
/// ```
716+
#[must_use]
698717
#[stable(feature = "rust1", since = "1.0.0")]
699718
#[inline]
700719
pub fn acos(self) -> f32 {
@@ -716,6 +735,7 @@ impl f32 {
716735
///
717736
/// assert!(abs_difference <= f32::EPSILON);
718737
/// ```
738+
#[must_use]
719739
#[stable(feature = "rust1", since = "1.0.0")]
720740
#[inline]
721741
pub fn atan(self) -> f32 {
@@ -794,6 +814,7 @@ impl f32 {
794814
///
795815
/// assert!(abs_difference <= f32::EPSILON);
796816
/// ```
817+
#[must_use]
797818
#[stable(feature = "rust1", since = "1.0.0")]
798819
#[inline]
799820
pub fn exp_m1(self) -> f32 {
@@ -815,6 +836,7 @@ impl f32 {
815836
///
816837
/// assert!(abs_difference <= f32::EPSILON);
817838
/// ```
839+
#[must_use]
818840
#[stable(feature = "rust1", since = "1.0.0")]
819841
#[inline]
820842
pub fn ln_1p(self) -> f32 {
@@ -838,6 +860,7 @@ impl f32 {
838860
///
839861
/// assert!(abs_difference <= f32::EPSILON);
840862
/// ```
863+
#[must_use]
841864
#[stable(feature = "rust1", since = "1.0.0")]
842865
#[inline]
843866
pub fn sinh(self) -> f32 {
@@ -861,6 +884,7 @@ impl f32 {
861884
/// // Same result
862885
/// assert!(abs_difference <= f32::EPSILON);
863886
/// ```
887+
#[must_use]
864888
#[stable(feature = "rust1", since = "1.0.0")]
865889
#[inline]
866890
pub fn cosh(self) -> f32 {
@@ -884,6 +908,7 @@ impl f32 {
884908
///
885909
/// assert!(abs_difference <= f32::EPSILON);
886910
/// ```
911+
#[must_use]
887912
#[stable(feature = "rust1", since = "1.0.0")]
888913
#[inline]
889914
pub fn tanh(self) -> f32 {
@@ -904,6 +929,7 @@ impl f32 {
904929
///
905930
/// assert!(abs_difference <= f32::EPSILON);
906931
/// ```
932+
#[must_use]
907933
#[stable(feature = "rust1", since = "1.0.0")]
908934
#[inline]
909935
pub fn asinh(self) -> f32 {
@@ -928,6 +954,7 @@ impl f32 {
928954
///
929955
/// assert!(abs_difference <= f32::EPSILON);
930956
/// ```
957+
#[must_use]
931958
#[stable(feature = "rust1", since = "1.0.0")]
932959
#[inline]
933960
pub fn acosh(self) -> f32 {
@@ -951,6 +978,7 @@ impl f32 {
951978
///
952979
/// assert!(abs_difference <= 1e-5);
953980
/// ```
981+
#[must_use]
954982
#[stable(feature = "rust1", since = "1.0.0")]
955983
#[inline]
956984
pub fn atanh(self) -> f32 {

0 commit comments

Comments
 (0)