[WIP] Introduce try_delete behind a type flag #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Slots explicitly created with the MayPanic support item deletion by
index (
try_delete), but in return have less powerful keys whose usemay result in panics (even when used in the non-try_ methods).
This is an alternative proposal for #5, equally drafty and more to support the discussion. Slots that use the alternative behavior are declared as
Slot<IT, N, MayPanic>in contrast to the defaultSlot<IT, N>which has aKeysAreValidin the policy position.It's a bit slimmer on the deltas, and probably a better idea altogether (especially as it does not make the key types any more complex, which might already become complex in the course of #4).
If this is taken as a route forward, it might be an option to only expose the non-try methods only for the default KeysAreValid variety of Slots, and to make the try methods accept either a usize or a key (for otherwise, access through an obtained key would be a bit awkward). The MayPanic variety indicator would need renaming in that case, but those names are straw men anyway.