Skip to content

Commit ee5880b

Browse files
adamreicholdbluss
authored andcommitted
Resolve needless_doctest_main Clippy lint in zipmacro module.
1 parent 55f3276 commit ee5880b

File tree

1 file changed

+39
-42
lines changed

1 file changed

+39
-42
lines changed

src/zip/zipmacro.rs

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,60 +42,57 @@
4242
///
4343
/// type M = Array2<f32>;
4444
///
45-
/// fn main() {
46-
/// // Setup example arrays
47-
/// let mut a = M::zeros((16, 16));
48-
/// let mut b = M::zeros(a.dim());
49-
/// let mut c = M::zeros(a.dim());
50-
///
51-
/// // assign values
52-
/// b.fill(1.);
53-
/// for ((i, j), elt) in c.indexed_iter_mut() {
54-
/// *elt = (i + 10 * j) as f32;
55-
/// }
56-
///
57-
/// // Example 1: Compute a simple ternary operation:
58-
/// // elementwise addition of b and c, stored in a
59-
/// azip!((a in &mut a, &b in &b, &c in &c) *a = b + c);
45+
/// // Setup example arrays
46+
/// let mut a = M::zeros((16, 16));
47+
/// let mut b = M::zeros(a.dim());
48+
/// let mut c = M::zeros(a.dim());
49+
///
50+
/// // assign values
51+
/// b.fill(1.);
52+
/// for ((i, j), elt) in c.indexed_iter_mut() {
53+
/// *elt = (i + 10 * j) as f32;
54+
/// }
6055
///
61-
/// assert_eq!(a, &b + &c);
56+
/// // Example 1: Compute a simple ternary operation:
57+
/// // elementwise addition of b and c, stored in a
58+
/// azip!((a in &mut a, &b in &b, &c in &c) *a = b + c);
6259
///
63-
/// // Example 2: azip!() with index
64-
/// azip!((index (i, j), &b in &b, &c in &c) {
65-
/// a[[i, j]] = b - c;
66-
/// });
60+
/// assert_eq!(a, &b + &c);
6761
///
68-
/// assert_eq!(a, &b - &c);
62+
/// // Example 2: azip!() with index
63+
/// azip!((index (i, j), &b in &b, &c in &c) {
64+
/// a[[i, j]] = b - c;
65+
/// });
6966
///
67+
/// assert_eq!(a, &b - &c);
7068
///
71-
/// // Example 3: azip!() on references
72-
/// // See the definition of the function below
73-
/// borrow_multiply(&mut a, &b, &c);
7469
///
75-
/// assert_eq!(a, &b * &c);
70+
/// // Example 3: azip!() on references
71+
/// // See the definition of the function below
72+
/// borrow_multiply(&mut a, &b, &c);
7673
///
74+
/// assert_eq!(a, &b * &c);
7775
///
78-
/// // Since this function borrows its inputs, the `IntoNdProducer`
79-
/// // expressions don't need to explicitly include `&mut` or `&`.
80-
/// fn borrow_multiply(a: &mut M, b: &M, c: &M) {
81-
/// azip!((a in a, &b in b, &c in c) *a = b * c);
82-
/// }
8376
///
77+
/// // Since this function borrows its inputs, the `IntoNdProducer`
78+
/// // expressions don't need to explicitly include `&mut` or `&`.
79+
/// fn borrow_multiply(a: &mut M, b: &M, c: &M) {
80+
/// azip!((a in a, &b in b, &c in c) *a = b * c);
81+
/// }
8482
///
85-
/// // Example 4: using azip!() without dereference in pattern.
86-
/// //
87-
/// // Create a new array `totals` with one entry per row of `a`.
88-
/// // Use azip to traverse the rows of `a` and assign to the corresponding
89-
/// // entry in `totals` with the sum across each row.
90-
/// //
91-
/// // The row is an array view; it doesn't need to be dereferenced.
92-
/// let mut totals = Array1::zeros(a.nrows());
93-
/// azip!((totals in &mut totals, row in a.rows()) *totals = row.sum());
9483
///
95-
/// // Check the result against the built in `.sum_axis()` along axis 1.
96-
/// assert_eq!(totals, a.sum_axis(Axis(1)));
97-
/// }
84+
/// // Example 4: using azip!() without dereference in pattern.
85+
/// //
86+
/// // Create a new array `totals` with one entry per row of `a`.
87+
/// // Use azip to traverse the rows of `a` and assign to the corresponding
88+
/// // entry in `totals` with the sum across each row.
89+
/// //
90+
/// // The row is an array view; it doesn't need to be dereferenced.
91+
/// let mut totals = Array1::zeros(a.nrows());
92+
/// azip!((totals in &mut totals, row in a.rows()) *totals = row.sum());
9893
///
94+
/// // Check the result against the built in `.sum_axis()` along axis 1.
95+
/// assert_eq!(totals, a.sum_axis(Axis(1)));
9996
/// ```
10097
#[macro_export]
10198
macro_rules! azip {

0 commit comments

Comments
 (0)