Skip to content

Conversation

@chrysn
Copy link
Contributor

@chrysn chrysn commented Apr 28, 2020

Slots explicitly created with the MayPanic support item deletion by
index (try_delete), but in return have less powerful keys whose use
may 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 default Slot<IT, N> which has a KeysAreValid in 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.

Slots explicitly created with the MayPanic support item deletion by
index (`try_delete`), but in return have less powerful keys whose use
may result in panics (even when used in the non-try_ methods).
@chrysn chrysn marked this pull request as draft April 28, 2020 12:59
@bugadani
Copy link
Owner

I think #10 would be a nicer solution. Similar idea with a bit nicer naming and less panics.

@chrysn
Copy link
Contributor Author

chrysn commented Apr 29, 2020

#10 is better than this, yes, closing this in favor of it (but we might still do better).

@chrysn chrysn closed this Apr 29, 2020
@bugadani
Copy link
Owner

Interesting, I haven't realized last night how close #10 was to your secound idea...

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.

2 participants