3 ms·
What happens if you find unsafe deeply nested in some dependency that you need? Like a web framework or maybe a graphics engine that's not so easy to find a rep
by lordnacho 4y ago
What happens if you find unsafe deeply nested in some dependency that you need? Like a web framework or maybe a graphics engine that's not so easy to find a replacement for?
- satvikpendem 4y agoWell, the simple answer is you don't use it. The more complex answer is that you do use it but have safe guards in place, which `unsafe` does to some extent even more than C or C++ code. You could also ask the creators of said dependencies why there is `unsafe` in their code and perhaps submit PRs to mitigate or remove that, as in the case of actix-web a few years ago. But as Rust crates become more prevalent, I do expect that we'll see fewer and fewer crates with `unsafe`, or have enough safe alternatives to `unsafe` crates.
- firstlink 4y ago> you do use it but have safe guards in place Isn't this the same thing that everyone else is doing, except they're not pretending to be special by falsely claiming that they're using no unsafe? My impression of `forbid(unsafe)` users in practice is that they think they've cleverly discovered a way to encapsulate unsafe that everyone else is missing, when in fact they've missed the point of unsafe to begin with and then belatedly rediscovered it.
- satvikpendem 4y agoI'm not sure what you're referring to with your 2 sentences exactly. What is "the same thing that everyone else is doing?" And what does this mean: "they've cleverly discovered a way to encapsulate unsafe that everyone else is missing, when in fact they've missed the point of unsafe to begin with and then belatedly rediscovered it?"