• calcopiritus@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    4 days ago

    With your definition this conversation doesn’t make sense though. Since rust’s direct array access doesn’t perform bounds checks when building in release mode. And it doesn’t require using unsafe.

    • AnyOldName3@lemmy.world
      link
      fedilink
      arrow-up
      1
      ·
      3 days ago

      That’s not what Rust’s documentation says. It does a compile-time bounds check if it can prove what the index might be during compilation, and a runtime bounds check if it can’t. In release mode, it tries harder to prove the maximum index is below the minimum length, but it still falls back to a runtime bounds check if it can’t unless you use get_unchecked, which is unsafe.