|
> dubiously-safe No, it's perfectly safe. Except if you expand the scope of "safe" by a lot. OP turned the socket into an (almost) raw file descriptor, and created an UDP socket from it. Weird, yes, but since it's perfectly memory safe and invalid operations would correctly error, it's not "dubiously-safe". It's safe. I mean, either your language has the ability to do raw (technically Owned in this case) file descriptors, or it doesn't. Maybe you'd prefer Rust had a third mode? Safe, `unsafe {}`, and `are_you_sure_you_understand_this {}`, the last one also being 'safe', but just… odd. |
> invalid operations would correctly error
At runtime, yes. I'm pointing out that Rust makes it possible to do better, and catch such issues at compile time.