Unsafe Blocks
Unsafe Blocks
Posted Apr 27, 2015 10:01 UTC (Mon) by ehiggs (guest, #90713)In reply to: Unsafe Blocks by gmatht
Parent article: Rust Once, Run Everywhere
"It also seems that you don't need unsafe blocks when defining an interface to a new python library."
Sure you don't need 'unsafe' in the interface, but if you look at the underlying code, large swathes of the implementation are marked 'unsafe'[1][2] for the obvious reasons.
"It would be even nicer if Rust could constraint untrusted code blocks, but apparently this is a too big an ask."
It would be nice, but it's probably orders of magnitude more difficult than offering a best effort at safety. And it would preclude the standard library from calling out to existing C libraries since they are all unsafe calls[3].
[1] https://github.com/lukemetz/rustpy/blob/master/src/base.rs
[2] https://github.com/lukemetz/rustpy/blob/master/src/ffi.rs
[3] e.g. std::num::f32::cos
