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

Index/IndexMut implementation #1

Closed
pliniker opened this issue Jan 12, 2016 · 3 comments
Closed

Index/IndexMut implementation #1

pliniker opened this issue Jan 12, 2016 · 3 comments

Comments

@pliniker
Copy link
Owner

  1. Currently they return a &T or &mut T just as a Vec or a slice, but similarly, they will panic on accessing an invalid index.

But Vec and slices are contiguous and the validity of an index is highly predictable. In the Trie, seeing it as a sparse form of a Vec, the validity of the index is highly unpredictable, making a panic very probable. This doesn't seem useful.

The accessors get() and get_mut() are much more practical.

  1. unwrap() should be replaced with expect(message) to give clear error messages on panic.
@pliniker
Copy link
Owner Author

Also, document the above in the code.

@pliniker
Copy link
Owner Author

Ideally, the IndexAssign trait would address the usefulness of using the indexing syntax.

@pliniker pliniker closed this as completed Mar 1, 2016
@pliniker
Copy link
Owner Author

pliniker commented Mar 1, 2016

Implemented (2) but nothing further to be done.

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

No branches or pull requests

1 participant