Skip to content

Commit 12878c6

Browse files
satisfying CI(cargo doc, etc.)
1 parent faf0fc0 commit 12878c6

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/impl_methods.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,11 +2553,11 @@ where
25532553
///
25542554
/// The cycle detection is done using a bitmask to track visited positions.
25552555
///
2556-
/// For example, axes from [0,1,2] to [2, 0, 1]
2557-
/// For axis values [1, 0, 2]:
2558-
/// 1 << 1; // 0b0001 << 1 = 0b0010 (decimal 2)
2559-
/// 1 << 0; // 0b0001 << 0 = 0b0001 (decimal 1)
2560-
/// 1 << 2; // 0b0001 << 2 = 0b0100 (decimal 4)
2556+
/// For example, axes from \[0,1,2\] to \[2, 0, 1\]
2557+
/// For axis values \[1, 0, 2\]:
2558+
/// 1 << 1 // 0b0001 << 1 = 0b0010 (decimal 2)
2559+
/// 1 << 0 // 0b0001 << 0 = 0b0001 (decimal 1)
2560+
/// 1 << 2 // 0b0001 << 2 = 0b0100 (decimal 4)
25612561
///
25622562
/// Each axis gets its own unique bit position in the bitmask:
25632563
/// - Axis 0: bit 0 (rightmost)
@@ -2567,13 +2567,15 @@ where
25672567
/// The check `(visited & (1 << axis)) != 0` works as follows:
25682568
/// ```no_run
25692569
/// let mut visited = 0; // 0b0000
2570+
/// let axis = 1;
2571+
/// let new_axis = 0;
25702572
/// // Check axis 1
2571-
/// if (visited & (1 << 1)) != 0 { // 0b0000 & 0b0010 = 0b0000
2573+
/// if (visited & (1 << axis)) != 0 { // 0b0000 & 0b0010 = 0b0000
25722574
/// // Not visited yet
25732575
/// }
25742576
/// // Mark axis 1 as visited
2575-
/// visited |= (1 << axis) | (1 << new_axis); /// // Check axis 1 again
2576-
/// if (visited & (1 << 1)) != 0 { // 0b0010 & 0b0010 = 0b0010
2577+
/// visited |= (1 << axis) | (1 << new_axis); // 0b0000 | 0b0010 | 0b0001 = 0b0011
2578+
/// if (visited & (1 << 1)) != 0 { // 0b0011 & 0b0010 = 0b0010
25772579
/// // Already visited!
25782580
/// }
25792581
/// ```
@@ -2614,13 +2616,9 @@ where
26142616
continue;
26152617
}
26162618

2617-
let temp = dim[axis];
2618-
dim[axis] = dim[new_axis];
2619-
dim[new_axis] = temp;
2619+
dim.swap(axis, new_axis);
2620+
strides.swap(axis, new_axis);
26202621

2621-
let temp = strides[axis];
2622-
strides[axis] = strides[new_axis];
2623-
strides[new_axis] = temp;
26242622
visited |= (1 << axis) | (1 << new_axis);
26252623
}
26262624
}

0 commit comments

Comments
 (0)