1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Fold-then-project and membership.
//
// Spliced into the `FluentIter` trait by `build.rs`. Names resolve in
// the crate-root scope of `lib.rs`, exactly as before the split.
/// ⇔ `.reduceAndMap(reducer, initial, resultFn)`: fold, then project the
/// accumulator. Argument order follows [`Iterator::fold`] (initial
/// first), not the JS signature.
///
/// ```
/// use fluent_iterable::FluentIter;
///
/// let report = [1, 2, 3]
/// .into_iter()
/// .reduce_and_map(0, |acc, x| acc + x, |sum| format!("total {sum}"));
/// assert_eq!(report, "total 6");
/// ```
/// ⇔ `.contains(item)`: any item equal to `item` (JS compares with
/// `===`; Rust uses [`PartialEq`]). Short-circuits on the first hit.
///
/// ```
/// use fluent_iterable::FluentIter;
///
/// assert!(["a", "b"].into_iter().contains(&"b"));
/// assert!(!["a", "b"].into_iter().contains(&"c"));
/// ```