Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add slice_axis_move method #1211

Merged
merged 1 commit into from
Mar 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/impl_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,16 @@ where
debug_assert!(self.pointer_is_inbounds());
}

/// Slice the array in place along the specified axis, then return the sliced array.
///
/// **Panics** if an index is out of bounds or step size is zero.<br>
/// **Panics** if `axis` is out of bounds.
#[must_use = "slice_axis_move returns an array with the sliced result"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I was going to ask about the must_use, ownership semantics should mean we don't need it. But ArrayViews can be copy, so it applies well there. Nice catch.

pub fn slice_axis_move(mut self, axis: Axis, indices: Slice) -> Self {
self.slice_axis_inplace(axis, indices);
self
}

/// Return a view of a slice of the array, with a closure specifying the
/// slice for each axis.
///
Expand Down