Re:A cryptographically secure bootloader for RISC-V in Rust
by RsmFz on Monday August 05, 2024 @12:07PM
(#41162612)
I think the phrase is "zero-cost abstractions", meaning "Supposing you want bounds checks, you may as well use ours and not roll your own"
Re:A cryptographically secure bootloader for RISC-V in Rust
by ladyanita22 on Monday August 05, 2024 @12:39PM
(#41162922)
It's true that you can escape them though. There are some other small things (which AFAICT you can escape from to as well)
Re:A cryptographically secure bootloader for RISC-V in Rust
by estebank on Monday August 05, 2024 @02:15PM
(#41163834)
> Indexing into an array adds bounds checks which takes non-zero time.
* When done in such a way that the compiler cannot know the access is in-bounds. The same code in C would also need to perform bounds checks on access. If you do the same assertion you would in C checking that the indices are always less than the length, then Rust will not perform the bounds check because it detects it's unnecessary. Leveraging iterators is one idiomatic way of avoiding those bounds checks.
For completeness, it's 0.1x the size with 1.20x the runtime, so these are not just language differences