4 ms·
Yeah I've been writing a lot of Rust for my compiler and it's so much fun. But it still bugs me that indexing panics. Returning an Option would make a lot more
by hardwaregeek 6y ago
Yeah I've been writing a lot of Rust for my compiler and it's so much fun. But it still bugs me that indexing panics. Returning an Option would make a lot more sense...
What I've been wondering for my own language is whether I could design something like Rust's borrow checker but for ranges of values. That way I can guarantee valid indexing.
- swsieber 6y agoVec does provide non panicking retrieval methods. You could newtype it and implement the indexing trait, delegating to the non-panicking methods.