Skip to content

Commit 08ad7a6

Browse files
committed
Mark .fold() deprecated
1 parent 258fba6 commit 08ad7a6

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

benches/bench1.rs

-11
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,6 @@ fn iter_sum_2d_cutout(bench: &mut test::Bencher)
116116
});
117117
}
118118

119-
#[bench]
120-
fn iter_sum_2d_cutout_fold(bench: &mut test::Bencher)
121-
{
122-
let a = OwnedArray::<i32, _>::zeros((66, 66));
123-
let av = a.slice(s![1..-1, 1..-1]);
124-
let a = black_box(av);
125-
bench.iter(|| {
126-
a.fold(0, |acc, elt| acc + *elt)
127-
});
128-
}
129-
130119
#[bench]
131120
fn iter_sum_2d_cutout_by_row(bench: &mut test::Bencher)
132121
{

src/impl_methods.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,12 @@ impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
10791079
}
10801080
}
10811081

1082+
/// ***Deprecated: Will be removed because it dictates a specific order.***
1083+
///
10821084
/// Traverse the array elements in order and apply a fold,
10831085
/// returning the resulting value.
1086+
#[cfg_attr(has_deprecated, deprecated(note=
1087+
"Will be removed because it dictates a specific order"))]
10841088
pub fn fold<'a, F, B>(&'a self, mut init: B, mut f: F) -> B
10851089
where F: FnMut(B, &'a A) -> B, A: 'a
10861090
{

src/impl_numeric.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl<A, S, D> ArrayBase<S, D>
7070
if let Some(slc) = row.as_slice() {
7171
sum = sum + numeric_util::unrolled_sum(slc);
7272
} else {
73-
sum = sum + row.fold(A::zero(), |acc, elt| acc + elt.clone());
73+
sum = sum + row.iter().fold(A::zero(), |acc, elt| acc + elt.clone());
7474
}
7575
}
7676
sum

0 commit comments

Comments
 (0)