Hi All,
I'm still trying to wrap my head around a real-life use case for unsafe code. Does anybody have an example (or repo) of some being used?
Many thanks,
Kev
Hi All,
I'm still trying to wrap my head around a real-life use case for unsafe code. Does anybody have an example (or repo) of some being used?
Many thanks,
Kev
The stdlib contains lots of them. For example, the Vec<T>
is implemented with unsafe code.
Thank you for this, I forgot to mention that I am aware that they are used in the stdlib. I was wondering what someone would use it for in a project example. I do appreciate the existence of unsafe code, but I was wondering where it'd be required in a project.
The Redox operating system kernel also contains handful of unsafe code.
Thank you, will have a look through this!
I addressed this in a recent related thread. FFI and interfacing to a GPU are two obvious uses that are currently unavoidable.
In general "unsafe" is not required in application code.
My plan is never to write "unsafe" into my applications. After all I don't in my Javascript/node.js or Python programs, why should I do it in Rust?
Well, actually we do use "unsafe" code in node.js and Python, not to mention C#, Java etc. We do it by writing modules in C or C++ that we can call from our application language.
Many times people have suggested use of "unsafe" to get C like performance from some Rust code I have presented here. Every time it has proved unnecessary, one could get the performance without "unsafe".
Thank you @ZiCog for taking the time to explan, very much appreciated!
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.