Skip to content

Add contains() method to check if an index is within array bounds#1593

Open
theoxfaber wants to merge 1 commit into
rust-ndarray:masterfrom
theoxfaber:add-contains-method
Open

Add contains() method to check if an index is within array bounds#1593
theoxfaber wants to merge 1 commit into
rust-ndarray:masterfrom
theoxfaber:add-contains-method

Conversation

@theoxfaber
Copy link
Copy Markdown

Adds a contains() method to ArrayBase to check whether a given index falls within array dimensions without accessing the element.

Closes #1247

let a = arr2(&[[1., 2.], [3., 4.]]);
assert!(a.contains((0, 1)));
assert!(!a.contains((2, 0)));

@akern40
Copy link
Copy Markdown
Collaborator

akern40 commented Jun 6, 2026

Could you please add a test or two on the new method? And rebase off of master as well, to fix potential CI issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array bounds/contains check?

2 participants