Open
Description
TL;DR version: Make vec[key]_? = new_value;
doesn't panic when key is out of bounds.
For Rust syntax budget, square bracket is perhaps one of the least rewarding current design at all. Every occurrence of square bracket reminds people the potential possibility of panicking. This might be suitable for the "error early if something goes wrong" style application, but for long running services, propagating the panic to the root of the thread callstack might not be a good idea.
This proposes putting an _
(underscore) between the bracket and the ?
operator to invoke new TryIndex{,Mut}
traits instead, returning a Result
with an error type, then perform ?
operator on that to return early.