• badmin@lemm.ee
    link
    fedilink
    arrow-up
    4
    ·
    1 day ago

    What happens if you use an out of range array subscript a[n]? Does that always return an option type?

    It never returns an option type. This Index interface happens to be actually noisy as implemented for some std types. Although you can implement it however you like for your own data types (including ones just wrapping the std ones). And we have checked access (example) and unchecked access (example) as methods.

    It’s actually astonishing the lengths you’re taking to NOT learn anything, to the point of just imagining things about Rust that are supposedly done wrong compared to Ada.