Skip to content

implement Stack::get and Index for #14#79

Open
kreinba wants to merge 1 commit into
yegor256:masterfrom
kreinba:14-stack-get
Open

implement Stack::get and Index for #14#79
kreinba wants to merge 1 commit into
yegor256:masterfrom
kreinba:14-stack-get

Conversation

@kreinba

@kreinba kreinba commented Jun 17, 2026

Copy link
Copy Markdown

Closes #14.

Adds Stack::get(&self, idx) -> Option<&V> and a corresponding Index<usize> implementation for Stack, mirroring the behavior of Vec::get and Vec's Index impl: get returns None when the index falls outside the populated range [0, len), while Index panics on the same condition with a message naming the index and the current length. The new public surface lives in a fresh src/access.rs module wired into src/lib.rs.

Verified locally with cargo test --all-features (29 unit tests pass, 2 doc-tests pass), cargo test --release --all-features, cargo fmt --check, cargo doc --no-deps, and cargo clippy --all-features -- --no-deps (no new warnings introduced; the seven pre-existing warnings on master are unchanged).

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.

Stack::get() is not implemented

1 participant