4 ms·
One of the barriers I've erected in my own head is whether my unsafe code is generic or not. As soon as your unsafe code starts depending on an arbitrary T (or
by burntsushi 10y ago
One of the barriers I've erected in my own head is whether my unsafe code is generic or not. As soon as your unsafe code starts depending on an arbitrary T (or some trait that T satisfies), then the scope of what you need to consider seems to widen quite a bit. I tend to either avoid this type of unsafe or find a way to constrain my problem. Using `unsafe` for pointer tricks or efficient movement of memory on concrete data types feels more self-contained to me, and therefore easier to verify.
(I don't have any particular point to make btw. Just sharing thoughts.)
- Manishearth 10y agoYeah, this is super important. I thought about it and I too tend to think very hard about generics here. As with all such things, it's harder to enumerate what's in your head :)