5 ms·
Rust also has runtime panics (e.g. indexing outside the bounds of a slice) - how does kernel Rust handle that?
by defen 2y ago
Rust also has runtime panics (e.g. indexing outside the bounds of a slice) - how does kernel Rust handle that?
- nine_k 2y agoStatic checks remove many more potential sources of panic. I suspect that with certain restraint one can write Rust code that is statically guaranteed to not panic. Also, Rust's panics may be recoverable, it's not necessarily fatal.
- whytevuhuni 2y agoIt does not, for slice indexing Rust is just as bad. My best guess is that this will likely blow up into such a big issue that the Rust devs are going to be forced to implement a feature to disable indexing (and leave just the safe .get()), or the kernel devs will fork the core library. But Rust prevents a myriad of other things that would be panics in Zig or undefined behavior in C. It has a really strong type system, capable of reducing a large amount of invalid states and keeping many invariants throughout very large codebases.