|
|
|
|
|
by tom_mellior
3272 days ago
|
|
Not to belabor the point, but... > the only bullet-proof way to limit the scope of unsafe code is at the module boundary with privacy I understand how this is meant in the context of that page, and it is true that modules protect against users messing with modules' internal invariants. But does that also work the other way around? In the example in https://gankro.github.io/blah/only-in-rust/#unbound-lifetime... it's not the caller messing with the callee's state, it's the callee messing up the caller's state. Do modules help at all here? That is, would the function fn foo<'a>(input: *const u32) -> &'a u32 {
unsafe {
return &*input
}
}
become less dangerous, or maybe impossible to call, when put into a module? |
|