Hacker News new | ask | show | jobs
by Ygg2 696 days ago
Yeah, you just renamed `unsafe`.

`unsafe` is the part where the compiler trusts you to uphold your own invariants, necessary to prevent Unsoundness. For example:

- unsafe fn get_unchecked(index) - compiler believes you will ensure index < length.

- unsafe fn set_capacity(capacity) - compiler trusts you will not set capacity to value that will cause UB. Even if its code boils essentially to set a field - which is safe according to Rust, but may invalidate other invariants preserving soundness.