Remix.run Logo
uecker an hour ago

I merely pointed out that the statement "Rust prefers to prevent all undefined behavior statically" is misleading in the sense that Rust does not do this for all undefined behavior.

LoganDark an hour ago | parent [-]

Maybe if you think of [] as offsetting a pointer rather than calling into an Index (or IndexMut) implementation. Since the return type isn't optional, a panic is the only way to avoid performing an invalid access or manufacturing an unfaithful return value. There are also optional accessors which do not panic, and unsafe/unchecked accessors.

uecker 35 minutes ago | parent [-]

Maybe? I think my statement is clearly correct in the way I formulated it.