Skip to content

Commit 6b25dca

Browse files
KmolYuanbluss
authored andcommitted
Apply partial suggestions.
1 parent 3296660 commit 6b25dca

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/impl_float_maths.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,22 @@ use crate::imp_prelude::*;
77
macro_rules! boolean_op {
88
($($(#[$meta1:meta])* fn $id1:ident $(#[$meta2:meta])* fn $id2:ident -> $func:ident)+) => {
99
$($(#[$meta1])*
10+
#[must_use = "method returns a new array and does not mutate the original value"]
1011
pub fn $id1(&self) -> Array<bool, D> {
1112
self.mapv(A::$func)
1213
}
1314
$(#[$meta2])*
15+
#[must_use = "method returns a new boolean value and does not mutate the original value"]
1416
pub fn $id2(&self) -> bool {
15-
self.mapv(A::$func).iter().any(|&b|b)
17+
self.mapv(A::$func).iter().any(|&b| b)
1618
})+
1719
};
1820
}
1921

2022
macro_rules! unary_op {
2123
($($(#[$meta:meta])* fn $id:ident)+) => {
2224
$($(#[$meta])*
25+
#[must_use = "method returns a new array and does not mutate the original value"]
2326
pub fn $id(&self) -> Array<A, D> {
2427
self.mapv(A::$id)
2528
})+
@@ -29,6 +32,7 @@ macro_rules! unary_op {
2932
macro_rules! binary_op {
3033
($($(#[$meta:meta])* fn $id:ident($ty:ty))+) => {
3134
$($(#[$meta])*
35+
#[must_use = "method returns a new array and does not mutate the original value"]
3236
pub fn $id(&self, rhs: $ty) -> Array<A, D> {
3337
self.mapv(|v| A::$id(v, rhs))
3438
})+
@@ -41,19 +45,19 @@ macro_rules! binary_op {
4145
impl<A, S, D> ArrayBase<S, D>
4246
where
4347
A: Float,
44-
S: RawData<Elem = A> + Data,
48+
S: Data<Elem = A>,
4549
D: Dimension,
4650
{
4751
boolean_op! {
4852
/// If the number is `NaN` (not a number), then `true` is returned for each element.
4953
fn is_nan
5054
/// Return `true` if any element is `NaN` (not a number).
51-
fn is_nan_any -> is_nan
55+
fn is_any_nan -> is_nan
5256

5357
/// If the number is infinity, then `true` is returned for each element.
5458
fn is_infinite
5559
/// Return `true` if any element is infinity.
56-
fn is_infinite_any -> is_infinite
60+
fn is_any_infinite -> is_infinite
5761
}
5862
unary_op! {
5963
/// The largest integer less than or equal to each element.
@@ -87,7 +91,7 @@ where
8791
/// Square root of each element.
8892
fn sqrt
8993

90-
/// `e^x` of each element. (Exponential function)
94+
/// `e^x` of each element (exponential function).
9195
fn exp
9296

9397
/// `2^x` of each element.
@@ -105,13 +109,13 @@ where
105109
/// Cubic root of each element.
106110
fn cbrt
107111

108-
/// Sine of each element. (in radians)
112+
/// Sine of each element (in radians).
109113
fn sin
110114

111-
/// Cosine of each element. (in radians)
115+
/// Cosine of each element (in radians).
112116
fn cos
113117

114-
/// Tangent of each element. (in radians)
118+
/// Tangent of each element (in radians).
115119
fn tan
116120

117121
/// Converts radians to degrees for each element.
@@ -136,9 +140,10 @@ where
136140
fn abs_sub(A)
137141
}
138142

139-
/// Square of each element.
140-
pub fn square(&self) -> Array<A, D> {
141-
self.mapv(|v| v * v)
143+
/// Square (two powers) of each element.
144+
#[must_use = "method returns a new array and does not mutate the original value"]
145+
pub fn pow2(&self) -> Array<A, D> {
146+
self.mapv(|v: A| v * v)
142147
}
143148

144149
/// Limit the values for each element.

0 commit comments

Comments
 (0)